[Fedora-directory-commits] adminutil/tests Makefile, NONE, 1.1 readme.txt, NONE, 1.1 retrieveSIE.c, NONE, 1.1

Noriko Hosoi (nhosoi) fedora-directory-commits at redhat.com
Wed Nov 16 18:50:28 UTC 2005


Author: nhosoi

Update of /cvs/dirsec/adminutil/tests
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv856/tests

Added Files:
	Makefile readme.txt retrieveSIE.c 
Log Message:



--- NEW FILE Makefile ---
#
# BEGIN COPYRIGHT BLOCK
# Copyright (C) 2005 Red Hat, Inc.
# All rights reserved.
# 
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation version
# 2.1 of the License.
#                                                                                  
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#                                                                                  
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
# END COPYRIGHT BLOCK
#

BUILD_ROOT=..

include ../nsconfig.mk

OBJDEST:=$(OBJDIR)/tests

OBJS:=$(OBJDEST)/retrieveSIE

all: $(OBJDEST) $(OBJS)

$(OBJDEST)/retrieveSIE: retrieveSIE.c
	$(CC) $(CFLAGS) $(MCC_INCLUDE) $< -o $@ $(NSPRLINK) $(LDAP_NOSSL_LINK) $(ICULINK) -L$(OBJDIR)/lib -ladminutil10

$(OBJDEST):
	-mkdir $(OBJDEST)

run: $(OBJDEST) $(OBJS)
	LD_LIBRARY_PATH=$(NSPR_LIBPATH):$(LDAPSDK_LIBPATH):$(ICU_LIBPATH):$(OBJDIR)/lib $(OBJDEST)/retrieveSIE $(SERVER_ROOT)


--- NEW FILE readme.txt ---
#
# BEGIN COPYRIGHT BLOCK
# Copyright (C) 2005 Red Hat, Inc.
# All rights reserved.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation version
# 2.1 of the License.
# 
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
# 
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
# END COPYRIGHT BLOCK
#

Test Case 1: test an api retrieveSIEs

How to run:
gmake [ INTERNAL_BUILD=1 ] run [ SERVER_ROOT=<your_directory_server_root> ]
default SERVER_ROOT: /opt/redhat-ds

Sample output:
$ gmake run SERVER_ROOT=/export/servers/ds72
Server Root: /export/servers/ds72
cn=slapd-laputa, cn=Fedora Directory Server, cn=Server Group, cn=laputa.sfbay.redhat.com, ou=sfbay.redhat.com, o=NetscapeRoot
SUCCESS: SIE is retrieved




--- NEW FILE retrieveSIE.c ---
/*
 * BEGIN COPYRIGHT BLOCK
 * Copyright (C) 2005 Red Hat, Inc.
 * All rights reserved.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation version
 * 2.1 of the License.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 * END COPYRIGHT BLOCK
 */
/*
 * retireveSIE.c: test program to test an API getServerDNList
 * Usage: retireveSIE [ <server_root> ]
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "libadminutil/admutil.h"
#include "libadminutil/srvutil.h"

main(int ac, char **av)
{
    AdmldapInfo ldapInfo = NULL;
    AttrNameList nameList = NULL;
    char *svrroot = "/opt/redhat-ds";
    char *admroot = NULL;
    int len = 0;
    int rval = 0;
    char **p;
    int siecnt = 0;

    if (ac > 1) {
        svrroot = strdup(*(av+1));
    }
    
    if (NULL == svrroot || 0 == strlen(svrroot)) {
        fprintf(stderr, "ERROR: server root was not specified.\n");
        exit(1);
    } else {
        fprintf(stdout, "%s: Server Root: %s\n", *av, svrroot);
    }

    len = strlen(svrroot) + 32;
    admroot = (char *)malloc(len);
    if (NULL == admroot) {
        fprintf(stderr, "ERROR: failed to allocate %d bytes\n", len);
        exit(1);
    }

    sprintf(admroot, "%s/admin-serv/config", svrroot);

    /*
     * get the LDAP information from admin server config info
     */
    ldapInfo = admldapBuildInfo(admroot, &rval);
    if (NULL == ldapInfo) {
        fprintf(stderr, "ERROR: empty ldapInfo\n");
        rval = 1;
        goto done;
    }

    /*
     * get servers' DNs belonging to the Admin Server
     */
    nameList = getServerDNList(ldapInfo);
    if (NULL == nameList) {
        fprintf(stderr, "ERROR: empty nameList\n");
        rval = 1;
        goto done;
    }

    for (p = nameList; p && *p; p++) {
        fprintf(stdout, "%s\n", *p);
        if (0 == strncasecmp(*p, "cn=", 3)) {
            siecnt++;
        }
    }
    if (siecnt > 0) {
        fprintf(stdout, "SUCCESS: SIE%s retrieved\n",  siecnt>1?"S are":" is");
    } else {
        fprintf(stdout, "FAILURE: SIE is not retrieved\n");
    }

done:
    free(admroot);
    exit(rval);
}




More information about the Fedora-directory-commits mailing list