[Prev][Next][Index][Thread]

# [server] how to make a builtin suspend

- Date: Fri, 15 Dec 1995 11:59:42 PST
- From:
- Content-Type: TEXT/PLAIN; charset=US-ASCII

    Hya,

    We have made a builtin, to check the password-entry from a user,  with
    yp_match. It works perfect, but it takes too long sometimes, to get the
    result. (the server may be down, or is just TOOOO slow;-)

    Now, does anybody know how to suspend such a task, but still does it's job?
    Like ONC() will timeout in future realeases, I'd like this in my
    nis_password.

    (i've added the code below (for hackers)...it belongs in server.c )

    anyone ideas?

    	Kai

    ---------------------%cuthere%--------------

    #include "execute.h"
    #include <rpcsvc/nis.h>
    #include <rpcsvc/ypclnt.h>
    #include <rpcsvc/yp_prot.h>

    extern const char* crypt( char*, char*);

    char* nisdomain;

    static package
    bf_nis_password(Var arglist, Byte next, void* vdata, Objid progr)
    {
    	Var r;
    	int yp_err, l;
    	char* p;
    	char* user;
    	char* password;
    	char* encryptedpw;

    	if (!is_wizard(progr))
    		return make_error_pack(E_PERM);

    	user = arglist.v.list[1].v.str;
    	password = arglist.v.list[2].v.str;
    	logf("NIS: checking user %s\n",user);

    	if ((yp_err = yp_match(nisdomain, "passwd.byname",user,strlen(user),&p,&l)))
    		{
            	if (yp_err == YPERR_KEY)
            		{
    			r.type = TYPE_NUM;
    			r.v.num = 0;
    			free_var(arglist);
    			return make_var_pack(r);
    			}
    		else
           		{

    			r.type = TYPE_STR;
    			r.v.str = strdup(yperr_string(yp_err));
    			logf("NIS: %s\n",yperr_string(yp_err));
    			free_var(arglist);
    			return make_var_pack(r);
    			}
    		}
    	encryptedpw = strstr(p, ":")+1;
    	*(strstr(encryptedpw, ":"))=0;

    	r.type = TYPE_NUM;
    	if(!strcmp(encryptedpw,crypt(password,encryptedpw)))
    		r.v.num = 1;
    	else
    		r.v.num = 0;
    	free(p);
    	free_var(arglist);
    	return make_var_pack(r);
    }
    /* and add this line at the bottom...you know, where all the registering is done */

        (void) register_function("nis_password",2,2, bf_nis_password,
        				TYPE_STR,TYPE_STR);

    -----------------------%Cut here%------------------

Follow-Ups:

- Re: [server] how to make a builtin suspend

- From: Pavel Curtis <pavel@parc.xerox.com>

- Prev: [SERVER, FUP] Re: db Stored on Disk???
- Next: Re: [server] how to make a builtin suspend
- Index: MOO-cows
- Thread: MOO-cows

Home | Subject Index | Thread Index