DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download
Index: T p

⟦268f3aec9⟧ TextFile

    Length: 4463 (0x116f)
    Types: TextFile
    Names: »passwd-resp.c«

Derivation

└─⟦3d0c2be1b⟧ Bits:30001254 ISODE-5.0 Tape
    └─⟦eba4602b1⟧ »./isode-5.0.tar.Z« 
        └─⟦d3ac74d73⟧ 
            └─⟦this⟧ »isode-5.0/doc/manual/passwd-resp.c« 
└─⟦2d1937cfd⟧ Bits:30007241 EUUGD22: P.P 5.0
    └─⟦35176feda⟧ »EurOpenD22/isode/isode-6.tar.Z« 
        └─⟦de7628f85⟧ 
            └─⟦this⟧ »isode-6.0/doc/manual/passwd-resp.c« 

TextFile

/* lookup_service.c - password lookup service -- responder */

#include <stdio.h>
#include <pwd.h>
#include "ryresponder.h"		/* for generic idempotent responders */
#include "PasswordLookup-ops.h"		/* operation definitions */
#include "PasswordLookup-types.h"	/* type definitions */


#define	xalloc(p, type) \
	((p) = (type) calloc (1, sizeof *(p)))

#define	salloc(s) \
	str2qb ((s), strlen (s), 1)


#ifdef	SYS5
struct passwd *getpwnam (), *getpwuid ();
#endif


/* DATA */

static char *myservice = "passwdstore";


					/* OPERATIONS */
int	op_lookupUser (), op_lookupUID ();

static struct dispatch dispatches[] = {
    "lookupUser", operation_PasswordLookup_lookupUser, op_lookupUser,

    "lookupUID", operation_PasswordLookup_lookupUID, op_lookupUID,

    NULL
};


/* MAIN */

/* ARGSUSED */

main (argc, argv, envp)
int	argc;
char  **argv,
      **envp;
{
    ryresponder (argc, argv, PLocalHostName (), myservice, dispatches,
	table_PasswordLookup_Operations, NULLIFP, NULLIFP);

    exit (0);			/* NOTREACHED */
}


/* OPERATIONS */

static int  op_lookupUser (sd, ryo, rox, in, roi)
int	sd;
struct RyOperation *ryo;
struct RoSAPinvoke *rox;
caddr_t	in;
struct RoSAPindication *roi;
{
    int     result;
    char   *cp;
    register struct type_PasswordLookup_UserName   *arg =
		(struct type_PasswordLookup_UserName   *) in;

    if (rox -> rox_nolinked == 0) {
	advise (LLOG_NOTICE, NULLCP,
		"RO-INVOKE.INDICATION/%d: %s, unknown linkage %d",
		sd, ryo -> ryo_name, rox -> rox_linkid);
	return ureject (sd, ROS_IP_LINKED, rox, roi);
    }
    if (debug)
	advise (LLOG_DEBUG, NULLCP, "RO-INVOKE.INDICATION/%d: %s",
		sd, ryo -> ryo_name);

    if ((cp = qb2str (arg)) == NULL)
	result = error (sd, error_PasswordLookup_congested, (caddr_t) NULL,
			rox, roi);
    else {
	result = lookup (sd, getpwnam (cp), rox, roi);
	free (cp);
    }

    return result;
}


static int  op_lookupUID (sd, ryo, rox, in, roi)
int	sd;
struct RyOperation *ryo;
struct RoSAPinvoke *rox;
caddr_t	in;
struct RoSAPindication *roi;
{
    register struct type_PasswordLookup_UserID   *arg =
		(struct type_PasswordLookup_UserID   *) in;

    if (rox -> rox_nolinked == 0) {
	advise (LLOG_EXCEPTIONS, NULLCP,
		"RO-INVOKE.INDICATION/%d: %s, unknown linkage %d",
		sd, ryo -> ryo_name, rox -> rox_linkid);
	return ureject (sd, ROS_IP_LINKED, rox, roi);
    }
    if (debug)
	advise (LLOG_DEBUG, NULLCP, "RO-INVOKE.INDICATION/%d: %s",
		sd, ryo -> ryo_name);

    return lookup (sd, getpwuid (arg -> arg), rox, roi);
}


static int  lookup (sd, pw, rox, roi)
int	sd;
struct passwd *pw;
struct RoSAPinvoke *rox;
struct RoSAPindication *roi;
{
    int	    result;

    if (pw) {
	register struct type_PasswordLookup_Passwd *res = NULL;

	if (xalloc (res, struct type_PasswordLookup_Passwd *) == NULL
		|| (res -> name = salloc (pw -> pw_name)) == NULL
		|| (*pw -> pw_passwd
			&& (res -> passwd = salloc (pw -> pw_passwd)) == NULL)
		|| xalloc (res -> uid, struct type_PasswordLookup_UserID *)
			== NULL
		|| xalloc (res -> gid, struct type_PasswordLookup_GroupID *)
			== NULL
		|| (pw -> pw_comment
			&& (res -> comment = salloc (pw -> pw_comment))
				== NULL)
		|| (pw -> pw_gecos
			&& (res -> gecos = salloc (pw -> pw_gecos)) == NULL)
		|| (pw -> pw_dir
			&& (res -> dir = salloc (pw -> pw_dir)) == NULL)
		|| (pw -> pw_shell
			&& (res -> shell = salloc (pw -> pw_shell))
				    == NULL))
	    result = error (sd, error_PasswordLookup_congested, (caddr_t) NULL,
		rox, roi);
	else {
	    res -> uid -> arg = pw -> pw_uid;
	    res -> gid -> arg = pw -> pw_gid;
	    res -> quota = pw -> pw_quota;

	    if (RyDsResult (sd, rox -> rox_id, (caddr_t) res, ROS_NOPRIO, roi)
		    == NOTOK)
		ros_adios (&roi -> roi_preject, "RESULT");
	    result = OK;
	}

	free_PasswordLookup_Passwd (res);
    }
    else
	result = error (sd, error_PasswordLookup_noSuchUser, (caddr_t) NULL,
		rox, roi);

    return result;
}


/* ERROR */

static int  error (sd, err, param, rox, roi)
int	sd,
	err;
caddr_t	param;
struct RoSAPinvoke *rox;
struct RoSAPindication *roi;
{
    if (RyDsError (sd, rox -> rox_id, err, param, ROS_NOPRIO, roi) == NOTOK)
	ros_adios (&roi -> roi_preject, "ERROR");

    return OK;
}


/* U-REJECT */

static int  ureject (sd, reason, rox, roi)
int	sd,
	reason;
struct RoSAPinvoke *rox;
struct RoSAPindication *roi;
{
    if (RyDsUReject (sd, rox -> rox_id, reason, ROS_NOPRIO, roi) == NOTOK)
	ros_adios (&roi -> roi_preject, "U-REJECT");

    return OK;
}