Annotation of 43BSDReno/contrib/isode-beta/others/lookup/lookupd.c, revision 1.1.1.1

1.1       root        1: /* lookupd.c - password lookup service -- responder */
                      2: 
                      3: #ifndef        lint
                      4: static char *rcsid = "$Header: /f/osi/others/lookup/RCS/lookupd.c,v 7.1 90/07/09 14:39:50 mrose Exp $";
                      5: #endif
                      6: 
                      7: /* 
                      8:  * $Header: /f/osi/others/lookup/RCS/lookupd.c,v 7.1 90/07/09 14:39:50 mrose Exp $
                      9:  *
                     10:  *
                     11:  * $Log:       lookupd.c,v $
                     12:  * Revision 7.1  90/07/09  14:39:50  mrose
                     13:  * sync
                     14:  * 
                     15:  * Revision 7.0  89/11/23  22:56:39  mrose
                     16:  * Release 6.0
                     17:  * 
                     18:  */
                     19: 
                     20: /*
                     21:  *                               NOTICE
                     22:  *
                     23:  *    Acquisition, use, and distribution of this module and related
                     24:  *    materials are subject to the restrictions of a license agreement.
                     25:  *    Consult the Preface in the User's Manual for the full terms of
                     26:  *    this agreement.
                     27:  *
                     28:  */
                     29: 
                     30: 
                     31: #include <stdio.h>
                     32: #include <pwd.h>
                     33: #include "ryresponder.h"       /* for generic idempotent responders */
                     34: #include "PasswordLookup-ops.h"                /* operation definitions */
                     35: #include "PasswordLookup-types.h"      /* type definitions */
                     36: 
                     37: 
                     38: #define        xalloc(p, type) \
                     39:        ((p) = (type) calloc (1, sizeof *(p)))
                     40: 
                     41: #define        salloc(s) \
                     42:        str2qb ((s), strlen (s), 1)
                     43: 
                     44: 
                     45: #ifdef SYS5
                     46: struct passwd *getpwnam (), *getpwuid ();
                     47: #endif
                     48: 
                     49: /*    DATA */
                     50: 
                     51: static char *myservice = "passwdstore";
                     52: 
                     53: static char *mycontext = "isode passwd lookup demo";
                     54: 
                     55: 
                     56:                                        /* OPERATIONS */
                     57: int    op_lookupUser (), op_lookupUID ();
                     58: 
                     59: static struct dispatch dispatches[] = {
                     60:     "lookupUser", operation_PasswordLookup_lookupUser, op_lookupUser,
                     61: 
                     62:     "lookupUID", operation_PasswordLookup_lookupUID, op_lookupUID,
                     63: 
                     64:     NULL
                     65: };
                     66: 
                     67: /*    MAIN */
                     68: 
                     69: /* ARGSUSED */
                     70: 
                     71: main (argc, argv, envp)
                     72: int    argc;
                     73: char  **argv,
                     74:       **envp;
                     75: {
                     76:     (void) ryresponder (argc, argv, PLocalHostName (), myservice, mycontext,
                     77:                        dispatches, table_PasswordLookup_Operations,
                     78:                        NULLIFP, NULLIFP);
                     79: 
                     80:     exit (0);                  /* NOTREACHED */
                     81: }
                     82: 
                     83: /*    OPERATIONS */
                     84: 
                     85: static int  op_lookupUser (sd, ryo, rox, in, roi)
                     86: int    sd;
                     87: struct RyOperation *ryo;
                     88: struct RoSAPinvoke *rox;
                     89: caddr_t        in;
                     90: struct RoSAPindication *roi;
                     91: {
                     92:     int     result;
                     93:     char   *cp;
                     94:     register struct type_PasswordLookup_UserName   *arg =
                     95:                (struct type_PasswordLookup_UserName   *) in;
                     96: 
                     97:     if (rox -> rox_nolinked == 0) {
                     98:        advise (LLOG_EXCEPTIONS, NULLCP,
                     99:                "RO-INVOKE.INDICATION/%d: %s, unknown linkage %d",
                    100:                sd, ryo -> ryo_name, rox -> rox_linkid);
                    101:        return ureject (sd, ROS_IP_LINKED, rox, roi);
                    102:     }
                    103:     if (debug)
                    104:        advise (LLOG_DEBUG, NULLCP, "RO-INVOKE.INDICATION/%d: %s",
                    105:                sd, ryo -> ryo_name);
                    106: 
                    107:     if ((cp = qb2str (arg)) == NULL)
                    108:        result = error (sd, error_PasswordLookup_congested, (caddr_t) NULL,
                    109:                        rox, roi);
                    110:     else {
                    111:        result = lookup (sd, getpwnam (cp), rox, roi);
                    112:        free (cp);
                    113:     }
                    114: 
                    115:     return result;
                    116: }
                    117: 
                    118: /*  */
                    119: 
                    120: static int  op_lookupUID (sd, ryo, rox, in, roi)
                    121: int    sd;
                    122: struct RyOperation *ryo;
                    123: struct RoSAPinvoke *rox;
                    124: caddr_t        in;
                    125: struct RoSAPindication *roi;
                    126: {
                    127:     register struct type_PasswordLookup_UserID   *arg =
                    128:                (struct type_PasswordLookup_UserID   *) in;
                    129: 
                    130:     if (rox -> rox_nolinked == 0) {
                    131:        advise (LLOG_EXCEPTIONS, NULLCP,
                    132:                "RO-INVOKE.INDICATION/%d: %s, unknown linkage %d",
                    133:                sd, ryo -> ryo_name, rox -> rox_linkid);
                    134:        return ureject (sd, ROS_IP_LINKED, rox, roi);
                    135:     }
                    136:     if (debug)
                    137:        advise (LLOG_DEBUG, NULLCP, "RO-INVOKE.INDICATION/%d: %s",
                    138:                sd, ryo -> ryo_name);
                    139: 
                    140:     return lookup (sd, getpwuid (arg -> parm), rox, roi);
                    141: }
                    142: 
                    143: /*  */
                    144: 
                    145: static int  lookup (sd, pw, rox, roi)
                    146: int    sd;
                    147: struct passwd *pw;
                    148: struct RoSAPinvoke *rox;
                    149: struct RoSAPindication *roi;
                    150: {
                    151:     int            result;
                    152: 
                    153:     if (pw) {
                    154:        register struct type_PasswordLookup_Passwd *res = NULL;
                    155: 
                    156:        if (xalloc (res, struct type_PasswordLookup_Passwd *) == NULL
                    157:                || (res -> name = salloc (pw -> pw_name)) == NULL
                    158:                || (*pw -> pw_passwd
                    159:                        && (res -> passwd = salloc (pw -> pw_passwd)) == NULL)
                    160:                || xalloc (res -> uid, struct type_PasswordLookup_UserID *)
                    161:                        == NULL
                    162:                || xalloc (res -> gid, struct type_PasswordLookup_GroupID *)
                    163:                        == NULL
                    164:                || (pw -> pw_comment
                    165:                        && (res -> comment = salloc (pw -> pw_comment))
                    166:                                == NULL)
                    167:                || (pw -> pw_gecos
                    168:                        && (res -> gecos = salloc (pw -> pw_gecos)) == NULL)
                    169:                || (pw -> pw_dir
                    170:                        && (res -> dir = salloc (pw -> pw_dir)) == NULL)
                    171:                || (pw -> pw_shell
                    172:                        && (res -> shell = salloc (pw -> pw_shell)) == NULL))
                    173:            result = error (sd, error_PasswordLookup_congested, (caddr_t) NULL,
                    174:                rox, roi);
                    175:        else {
                    176:            res -> uid -> parm = pw -> pw_uid;
                    177:            res -> gid -> parm = pw -> pw_gid;
                    178: /* 
                    179:            res -> quota = pw -> pw_quota;
                    180:  */
                    181: 
                    182:            if (RyDsResult (sd, rox -> rox_id, (caddr_t) res, ROS_NOPRIO, roi)
                    183:                    == NOTOK)
                    184:                ros_adios (&roi -> roi_preject, "RESULT");
                    185:            result = OK;
                    186:        }
                    187: 
                    188:        free_PasswordLookup_Passwd (res);
                    189:     }
                    190:     else
                    191:        result = error (sd, error_PasswordLookup_noSuchUser, (caddr_t) NULL,
                    192:                rox, roi);
                    193: 
                    194:     return result;
                    195: }
                    196: 
                    197: /*    ERROR */
                    198: 
                    199: static int  error (sd, err, param, rox, roi)
                    200: int    sd,
                    201:        err;
                    202: caddr_t        param;
                    203: struct RoSAPinvoke *rox;
                    204: struct RoSAPindication *roi;
                    205: {
                    206:     if (RyDsError (sd, rox -> rox_id, err, param, ROS_NOPRIO, roi) == NOTOK)
                    207:        ros_adios (&roi -> roi_preject, "ERROR");
                    208: 
                    209:     return OK;
                    210: }
                    211: 
                    212: /*    U-REJECT */
                    213: 
                    214: static int  ureject (sd, reason, rox, roi)
                    215: int    sd,
                    216:        reason;
                    217: struct RoSAPinvoke *rox;
                    218: struct RoSAPindication *roi;
                    219: {
                    220:     if (RyDsUReject (sd, rox -> rox_id, reason, ROS_NOPRIO, roi) == NOTOK)
                    221:        ros_adios (&roi -> roi_preject, "U-REJECT");
                    222: 
                    223:     return OK;
                    224: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.