WARNSify, KNFify
This commit is contained in:
parent
b592c266f8
commit
736ba086df
36
usr.sbin/rpc.pcnfsd/extern.h
Normal file
36
usr.sbin/rpc.pcnfsd/extern.h
Normal file
@ -0,0 +1,36 @@
|
||||
/* $NetBSD: extern.h,v 1.1 1997/10/25 13:45:55 lukem Exp $ */
|
||||
|
||||
extern int interrupted;
|
||||
extern pr_list printers;
|
||||
extern pr_queue queue;
|
||||
extern char sp_name[1024];
|
||||
|
||||
void add_printer_alias __P((char *, char *, char *));
|
||||
void add_cache_entry __P((struct passwd *));
|
||||
int build_pr_list __P((void));
|
||||
pirstat build_pr_queue __P((printername, username, int, int *, int *));
|
||||
int check_cache __P((char *, char *, int *, int *));
|
||||
void free_mapreq_results __P((mapreq_res));
|
||||
void fillin_extra_groups __P((char *, u_int, int *, u_int[]));
|
||||
#ifdef USE_YP
|
||||
char *find_entry __P((char *, char *));
|
||||
#endif
|
||||
void free_pr_list_item __P((pr_list));
|
||||
void free_pr_queue_item __P((pr_queue));
|
||||
struct passwd *get_password __P((char *));
|
||||
pirstat get_pr_status __P((printername, bool_t *, bool_t *, int *,
|
||||
bool_t *, char *));
|
||||
void *grab __P((int));
|
||||
pcrstat pr_cancel __P((char *, char *, char *));
|
||||
pirstat pr_init __P((char *, char *, char **));
|
||||
psrstat pr_start __P((void));
|
||||
psrstat pr_start2 __P((char *, char *, char *, char *, char *,
|
||||
char **));
|
||||
void run_ps630 __P((char *, char *));
|
||||
void scramble __P((char *, char *));
|
||||
int strembedded __P((const char *, const char *));
|
||||
FILE *su_popen __P((char *, char *, int));
|
||||
int su_pclose __P((FILE *));
|
||||
#ifdef WTMP
|
||||
void wlogin __P((char *, struct svc_req *));
|
||||
#endif
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: pcnfsd.x,v 1.2 1995/07/25 22:20:33 gwr Exp $ */
|
||||
/* $NetBSD: pcnfsd.x,v 1.3 1997/10/25 13:45:56 lukem Exp $ */
|
||||
|
||||
/* The maximum number of bytes in a user name argument */
|
||||
const IDENTLEN = 32;
|
||||
@ -630,9 +630,9 @@ program PCNFSDPROG {
|
||||
** The following forces a publically-visible msg_out()
|
||||
*/
|
||||
%#if RPC_SVC
|
||||
% static void _msgout();
|
||||
% static void _msgout __P((char *));
|
||||
% void msg_out(msg) char *msg; {_msgout(msg);}
|
||||
%#endif
|
||||
%#if RPC_HDR
|
||||
% extern void msg_out();
|
||||
% extern void msg_out __P((char *));
|
||||
%#endif
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: pcnfsd_cache.c,v 1.2 1995/07/25 22:20:37 gwr Exp $ */
|
||||
/* $NetBSD: pcnfsd_cache.c,v 1.3 1997/10/25 13:45:57 lukem Exp $ */
|
||||
|
||||
/* RE_SID: @(%)/usr/dosnfs/shades_SCCS/unix/pcnfsd/v2/src/SCCS/s.pcnfsd_cache.c 1.1 91/09/03 12:45:14 SMI */
|
||||
/*
|
||||
@ -7,7 +7,6 @@
|
||||
** @(#)pcnfsd_cache.c 1.1 9/3/91
|
||||
**=====================================================================
|
||||
*/
|
||||
#include "common.h"
|
||||
/*
|
||||
**=====================================================================
|
||||
** I N C L U D E F I L E S E C T I O N *
|
||||
@ -17,15 +16,16 @@
|
||||
** exclusion of the files conditional on this. *
|
||||
**=====================================================================
|
||||
*/
|
||||
#include "pcnfsd.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <pwd.h>
|
||||
#include <errno.h>
|
||||
#include <pwd.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
extern char *crypt();
|
||||
|
||||
#include "common.h"
|
||||
#include "pcnfsd.h"
|
||||
#include "extern.h"
|
||||
|
||||
/*
|
||||
**---------------------------------------------------------------------
|
||||
@ -33,72 +33,64 @@ extern char *crypt();
|
||||
**---------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
extern int errno;
|
||||
|
||||
#ifdef USER_CACHE
|
||||
#define CACHE_SIZE 16 /* keep it small, as linear searches are
|
||||
* done */
|
||||
struct cache
|
||||
{
|
||||
int cuid;
|
||||
int cgid;
|
||||
char cpw[32];
|
||||
char cuname[10]; /* keep this even for machines
|
||||
* with alignment problems */
|
||||
}User_cache[CACHE_SIZE];
|
||||
|
||||
#define CACHE_SIZE 16 /* keep it small, as linear searches are done */
|
||||
struct cache {
|
||||
int cuid;
|
||||
int cgid;
|
||||
char cpw[32];
|
||||
char cuname[10]; /* keep this even for machines with alignment
|
||||
* problems */
|
||||
} User_cache[CACHE_SIZE];
|
||||
|
||||
|
||||
/*
|
||||
**---------------------------------------------------------------------
|
||||
** User cache support procedures
|
||||
** User cache support procedures
|
||||
**---------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
int
|
||||
check_cache(name, pw, p_uid, p_gid)
|
||||
char *name;
|
||||
char *pw;
|
||||
int *p_uid;
|
||||
int *p_gid;
|
||||
char *name;
|
||||
char *pw;
|
||||
int *p_uid;
|
||||
int *p_gid;
|
||||
{
|
||||
int i;
|
||||
int c1, c2;
|
||||
int i;
|
||||
int c1, c2;
|
||||
|
||||
for (i = 0; i < CACHE_SIZE; i++) {
|
||||
if (!strcmp(User_cache[i].cuname, name)) {
|
||||
c1 = strlen(pw);
|
||||
c2 = strlen(User_cache[i].cpw);
|
||||
if ((!c1 && !c2) ||
|
||||
!(strcmp(User_cache[i].cpw,
|
||||
crypt(pw, User_cache[i].cpw)))) {
|
||||
*p_uid = User_cache[i].cuid;
|
||||
*p_gid = User_cache[i].cgid;
|
||||
return (1);
|
||||
}
|
||||
User_cache[i].cuname[0] = '\0'; /* nuke entry */
|
||||
return (0);
|
||||
}
|
||||
c1 = strlen(pw);
|
||||
c2 = strlen(User_cache[i].cpw);
|
||||
if ((!c1 && !c2) ||
|
||||
!(strcmp(User_cache[i].cpw,
|
||||
crypt(pw, User_cache[i].cpw)))) {
|
||||
*p_uid = User_cache[i].cuid;
|
||||
*p_gid = User_cache[i].cgid;
|
||||
return (1);
|
||||
}
|
||||
User_cache[i].cuname[0] = '\0'; /* nuke entry */
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
add_cache_entry(p)
|
||||
struct passwd *p;
|
||||
struct passwd *p;
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
for (i = CACHE_SIZE - 1; i > 0; i--)
|
||||
User_cache[i] = User_cache[i - 1];
|
||||
User_cache[0].cuid = p->pw_uid;
|
||||
User_cache[0].cgid = p->pw_gid;
|
||||
(void)strcpy(User_cache[0].cpw, p->pw_passwd);
|
||||
(void)strcpy(User_cache[0].cuname, p->pw_name);
|
||||
(void) strcpy(User_cache[0].cpw, p->pw_passwd);
|
||||
(void) strcpy(User_cache[0].cuname, p->pw_name);
|
||||
}
|
||||
|
||||
|
||||
#endif /* USER_CACHE */
|
||||
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: pcnfsd_misc.c,v 1.2 1995/07/25 22:20:42 gwr Exp $ */
|
||||
/* $NetBSD: pcnfsd_misc.c,v 1.3 1997/10/25 13:45:57 lukem Exp $ */
|
||||
|
||||
/* RE_SID: @(%)/usr/dosnfs/shades_SCCS/unix/pcnfsd/v2/src/SCCS/s.pcnfsd_misc.c 1.5 92/01/24 19:59:13 SMI */
|
||||
/*
|
||||
@ -7,7 +7,6 @@
|
||||
** @(#)pcnfsd_misc.c 1.5 1/24/92
|
||||
**=====================================================================
|
||||
*/
|
||||
#include "common.h"
|
||||
/*
|
||||
**=====================================================================
|
||||
** I N C L U D E F I L E S E C T I O N *
|
||||
@ -17,19 +16,26 @@
|
||||
** exclusion of the files conditional on this. *
|
||||
**=====================================================================
|
||||
*/
|
||||
#include "pcnfsd.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <pwd.h>
|
||||
#include <sys/file.h>
|
||||
#include <signal.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <netdb.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <netdb.h>
|
||||
#include <pwd.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef ISC_2_0
|
||||
#include <sys/fcntl.h>
|
||||
@ -40,228 +46,226 @@
|
||||
#endif
|
||||
|
||||
#ifdef WTMP
|
||||
int wtmp_enabled = 1;
|
||||
int wtmp_enabled = 1;
|
||||
#endif
|
||||
|
||||
#ifdef USE_GETUSERSHELL
|
||||
extern char *getusershell();
|
||||
#endif
|
||||
#include "common.h"
|
||||
#include "pcnfsd.h"
|
||||
#include "extern.h"
|
||||
|
||||
/*
|
||||
**---------------------------------------------------------------------
|
||||
** Other #define's
|
||||
** Other #define's
|
||||
**---------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#define zchar 0x5b
|
||||
|
||||
char tempstr[256];
|
||||
extern char sp_name[1024]; /* in pcnfsd_print.c */
|
||||
char tempstr[256];
|
||||
|
||||
char *mapfont __P((char, char, char));
|
||||
void myhandler __P((int));
|
||||
void start_watchdog __P((int));
|
||||
void stop_watchdog __P((void));
|
||||
|
||||
/*
|
||||
**=====================================================================
|
||||
** C O D E S E C T I O N * **=====================================================================
|
||||
** C O D E S E C T I O N *
|
||||
**=====================================================================
|
||||
*/
|
||||
/*
|
||||
**---------------------------------------------------------------------
|
||||
** Support procedures
|
||||
** Support procedures
|
||||
**---------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
void
|
||||
scramble(s1, s2)
|
||||
char *s1;
|
||||
char *s2;
|
||||
char *s1;
|
||||
char *s2;
|
||||
{
|
||||
while (*s1)
|
||||
{
|
||||
*s2++ = (*s1 ^ zchar) & 0x7f;
|
||||
s1++;
|
||||
}
|
||||
while (*s1) {
|
||||
*s2++ = (*s1 ^ zchar) & 0x7f;
|
||||
s1++;
|
||||
}
|
||||
*s2 = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
struct passwd *
|
||||
struct passwd *
|
||||
get_password(usrnam)
|
||||
char *usrnam;
|
||||
char *usrnam;
|
||||
{
|
||||
struct passwd *p;
|
||||
static struct passwd localp;
|
||||
char *pswd;
|
||||
char *ushell;
|
||||
int ok = 0;
|
||||
struct passwd *p;
|
||||
static struct passwd localp;
|
||||
char *pswd;
|
||||
char *ushell;
|
||||
|
||||
|
||||
#ifdef SHADOW_SUPPORT
|
||||
struct spwd *sp;
|
||||
int shadowfile;
|
||||
struct spwd *sp;
|
||||
int shadowfile;
|
||||
#endif
|
||||
|
||||
#ifdef SHADOW_SUPPORT
|
||||
/*
|
||||
**--------------------------------------------------------------
|
||||
** Check the existence of SHADOW. If it is there, then we are
|
||||
** running a two-password-file system.
|
||||
**--------------------------------------------------------------
|
||||
*/
|
||||
/*
|
||||
**--------------------------------------------------------------
|
||||
** Check the existence of SHADOW. If it is there, then we are
|
||||
** running a two-password-file system.
|
||||
**--------------------------------------------------------------
|
||||
*/
|
||||
if (access(SHADOW, 0))
|
||||
shadowfile = 0; /* SHADOW is not there */
|
||||
shadowfile = 0; /* SHADOW is not there */
|
||||
else
|
||||
shadowfile = 1;
|
||||
shadowfile = 1;
|
||||
|
||||
setpwent();
|
||||
if (shadowfile)
|
||||
(void) setspent(); /* Setting the shadow password
|
||||
* file */
|
||||
if ((p = getpwnam(usrnam)) == (struct passwd *)NULL ||
|
||||
(shadowfile && (sp = getspnam(usrnam)) == (struct spwd *)NULL))
|
||||
return ((struct passwd *)NULL);
|
||||
(void) setspent(); /* Setting the shadow password file */
|
||||
if ((p = getpwnam(usrnam)) == (struct passwd *) NULL ||
|
||||
(shadowfile && (sp = getspnam(usrnam)) == (struct spwd *) NULL))
|
||||
return ((struct passwd *) NULL);
|
||||
|
||||
if (shadowfile)
|
||||
{
|
||||
pswd = sp->sp_pwdp;
|
||||
(void) endspent();
|
||||
}
|
||||
else
|
||||
pswd = p->pw_passwd;
|
||||
if (shadowfile) {
|
||||
pswd = sp->sp_pwdp;
|
||||
(void) endspent();
|
||||
} else
|
||||
pswd = p->pw_passwd;
|
||||
|
||||
#else
|
||||
p = getpwnam(usrnam);
|
||||
if (p == (struct passwd *)NULL)
|
||||
return ((struct passwd *)NULL);
|
||||
if (p == (struct passwd *) NULL)
|
||||
return ((struct passwd *) NULL);
|
||||
pswd = p->pw_passwd;
|
||||
#endif
|
||||
|
||||
#ifdef ISC_2_0
|
||||
/*
|
||||
**-----------------------------------------------------------
|
||||
** We may have an 'x' in which case look in /etc/shadow ..
|
||||
**-----------------------------------------------------------
|
||||
*/
|
||||
if (((strlen(pswd)) == 1) && pswd[0] == 'x')
|
||||
{
|
||||
struct spwd *shadow = getspnam(usrnam);
|
||||
/* *----------------------------------------------------------- * We
|
||||
* may have an 'x' in which case look in /etc/shadow ..
|
||||
* *----------------------------------------------------------- */
|
||||
if (((strlen(pswd)) == 1) && pswd[0] == 'x') {
|
||||
struct spwd *shadow = getspnam(usrnam);
|
||||
|
||||
if (!shadow)
|
||||
return ((struct passwd *)NULL);
|
||||
pswd = shadow->sp_pwdp;
|
||||
}
|
||||
if (!shadow)
|
||||
return ((struct passwd *) NULL);
|
||||
pswd = shadow->sp_pwdp;
|
||||
}
|
||||
#endif
|
||||
localp = *p;
|
||||
localp.pw_passwd = pswd;
|
||||
#ifdef USE_GETUSERSHELL
|
||||
|
||||
setusershell();
|
||||
while(ushell = getusershell()){
|
||||
if(!strcmp(ushell, localp.pw_shell)) {
|
||||
while (ushell = getusershell()) {
|
||||
if (!strcmp(ushell, localp.pw_shell)) {
|
||||
ok = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
endusershell();
|
||||
if(!ok)
|
||||
return ((struct passwd *)NULL);
|
||||
if (!ok)
|
||||
return ((struct passwd *) NULL);
|
||||
#else
|
||||
/*
|
||||
* the best we can do is to ensure that the shell ends in "sh"
|
||||
*/
|
||||
* the best we can do is to ensure that the shell ends in "sh"
|
||||
*/
|
||||
ushell = localp.pw_shell;
|
||||
if(strlen(ushell) < 2)
|
||||
return ((struct passwd *)NULL);
|
||||
if (strlen(ushell) < 2)
|
||||
return ((struct passwd *) NULL);
|
||||
ushell += strlen(ushell) - 2;
|
||||
if(strcmp(ushell, "sh"))
|
||||
return ((struct passwd *)NULL);
|
||||
if (strcmp(ushell, "sh"))
|
||||
return ((struct passwd *) NULL);
|
||||
|
||||
#endif
|
||||
return (&localp);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
**---------------------------------------------------------------------
|
||||
** Print support procedures
|
||||
** Print support procedures
|
||||
**---------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
char *
|
||||
|
||||
char *
|
||||
mapfont(f, i, b)
|
||||
char f;
|
||||
char i;
|
||||
char b;
|
||||
char f;
|
||||
char i;
|
||||
char b;
|
||||
{
|
||||
static char fontname[64];
|
||||
static char fontname[64];
|
||||
|
||||
fontname[0] = 0; /* clear it out */
|
||||
|
||||
switch (f) {
|
||||
case 'c':
|
||||
(void)strcpy(fontname, "Courier");
|
||||
(void) strcpy(fontname, "Courier");
|
||||
break;
|
||||
case 'h':
|
||||
(void)strcpy(fontname, "Helvetica");
|
||||
(void) strcpy(fontname, "Helvetica");
|
||||
break;
|
||||
case 't':
|
||||
(void)strcpy(fontname, "Times");
|
||||
(void) strcpy(fontname, "Times");
|
||||
break;
|
||||
default:
|
||||
(void)strcpy(fontname, "Times-Roman");
|
||||
goto finis ;
|
||||
(void) strcpy(fontname, "Times-Roman");
|
||||
goto finis;
|
||||
}
|
||||
if (i != 'o' && b != 'b') { /* no bold or oblique */
|
||||
if (f == 't') /* special case Times */
|
||||
(void)strcat(fontname, "-Roman");
|
||||
(void) strcat(fontname, "-Roman");
|
||||
goto finis;
|
||||
}
|
||||
(void)strcat(fontname, "-");
|
||||
(void) strcat(fontname, "-");
|
||||
if (b == 'b')
|
||||
(void)strcat(fontname, "Bold");
|
||||
(void) strcat(fontname, "Bold");
|
||||
if (i == 'o') /* o-blique */
|
||||
(void)strcat(fontname, f == 't' ? "Italic" : "Oblique");
|
||||
(void) strcat(fontname, f == 't' ? "Italic" : "Oblique");
|
||||
|
||||
finis: return (&fontname[0]);
|
||||
}
|
||||
|
||||
/*
|
||||
* run_ps630 performs the Diablo 630 emulation filtering process. ps630
|
||||
* was broken in certain Sun releases: it would not accept point size or
|
||||
* font changes. If your version is fixed, undefine the symbol
|
||||
* PS630_IS_BROKEN and rebuild pc-nfsd.
|
||||
*/
|
||||
* run_ps630 performs the Diablo 630 emulation filtering process. ps630
|
||||
* was broken in certain Sun releases: it would not accept point size or
|
||||
* font changes. If your version is fixed, undefine the symbol
|
||||
* PS630_IS_BROKEN and rebuild pc-nfsd.
|
||||
*/
|
||||
/* #define PS630_IS_BROKEN 1 */
|
||||
|
||||
void
|
||||
run_ps630(f, opts)
|
||||
char *f;
|
||||
char *opts;
|
||||
char *f;
|
||||
char *opts;
|
||||
{
|
||||
char temp_file[256];
|
||||
char commbuf[256];
|
||||
int i;
|
||||
char temp_file[256];
|
||||
char commbuf[256];
|
||||
int i;
|
||||
|
||||
(void)strcpy(temp_file, f);
|
||||
(void)strcat(temp_file, "X"); /* intermediate file name */
|
||||
(void) strcpy(temp_file, f);
|
||||
(void) strcat(temp_file, "X"); /* intermediate file name */
|
||||
|
||||
#ifndef PS630_IS_BROKEN
|
||||
(void)sprintf(commbuf, "ps630 -s %c%c -p %s -f ",
|
||||
opts[2], opts[3], temp_file);
|
||||
(void)strcat(commbuf, mapfont(opts[4], opts[5], opts[6]));
|
||||
(void)strcat(commbuf, " -F ");
|
||||
(void)strcat(commbuf, mapfont(opts[7], opts[8], opts[9]));
|
||||
(void)strcat(commbuf, " ");
|
||||
(void)strcat(commbuf, f);
|
||||
#else /* PS630_IS_BROKEN */
|
||||
/*
|
||||
* The pitch and font features of ps630 appear to be broken at
|
||||
* this time.
|
||||
*/
|
||||
(void)sprintf(commbuf, "ps630 -p %s %s", temp_file, f);
|
||||
#endif /* PS630_IS_BROKEN */
|
||||
(void) sprintf(commbuf, "ps630 -s %c%c -p %s -f ",
|
||||
opts[2], opts[3], temp_file);
|
||||
(void) strcat(commbuf, mapfont(opts[4], opts[5], opts[6]));
|
||||
(void) strcat(commbuf, " -F ");
|
||||
(void) strcat(commbuf, mapfont(opts[7], opts[8], opts[9]));
|
||||
(void) strcat(commbuf, " ");
|
||||
(void) strcat(commbuf, f);
|
||||
#else /* PS630_IS_BROKEN */
|
||||
/*
|
||||
* The pitch and font features of ps630 appear to be broken at
|
||||
* this time.
|
||||
*/
|
||||
(void) sprintf(commbuf, "ps630 -p %s %s", temp_file, f);
|
||||
#endif /* PS630_IS_BROKEN */
|
||||
|
||||
|
||||
if (i = system(commbuf)) {
|
||||
if ((i = system(commbuf)) != 0) {
|
||||
/*
|
||||
* Under (un)certain conditions, ps630 may return -1 even
|
||||
* if it worked. Hence the commenting out of this error
|
||||
@ -279,10 +283,11 @@ run_ps630(f, opts)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
**---------------------------------------------------------------------
|
||||
** WTMP update support
|
||||
** WTMP update support
|
||||
**---------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
@ -297,26 +302,25 @@ run_ps630(f, opts)
|
||||
|
||||
void
|
||||
wlogin(name, req)
|
||||
char *name;
|
||||
char *name;
|
||||
struct svc_req *req;
|
||||
{
|
||||
extern char *inet_ntoa();
|
||||
struct sockaddr_in *who;
|
||||
struct hostent *hp;
|
||||
char *host;
|
||||
char *host;
|
||||
struct utmp ut;
|
||||
int fd;
|
||||
int fd;
|
||||
|
||||
if(!wtmp_enabled)
|
||||
if (!wtmp_enabled)
|
||||
return;
|
||||
|
||||
/* Get network address of client. */
|
||||
/* Get network address of client. */
|
||||
who = &req->rq_xprt->xp_raddr;
|
||||
|
||||
/* Get name of connected client */
|
||||
hp = gethostbyaddr((char *)&who->sin_addr,
|
||||
sizeof (struct in_addr),
|
||||
who->sin_family);
|
||||
/* Get name of connected client */
|
||||
hp = gethostbyaddr((char *) &who->sin_addr,
|
||||
sizeof(struct in_addr),
|
||||
who->sin_family);
|
||||
|
||||
if (hp && (strlen(hp->h_name) <= sizeof(ut.ut_host))) {
|
||||
host = hp->h_name;
|
||||
@ -325,20 +329,21 @@ wlogin(name, req)
|
||||
}
|
||||
|
||||
(void) strcpy(ut.ut_line, "PC-NFS");
|
||||
(void) strncpy(ut.ut_name,name,sizeof ut.ut_name);
|
||||
(void) strncpy(ut.ut_name, name, sizeof ut.ut_name);
|
||||
(void) strncpy(ut.ut_host, host, sizeof ut.ut_host);
|
||||
ut.ut_time = time( (time_t *) 0);
|
||||
ut.ut_time = time((time_t *) 0);
|
||||
|
||||
if ((fd = open(_PATH_WTMP, O_WRONLY|O_APPEND, 0)) >= 0) {
|
||||
(void)write(fd, (char *)&ut, sizeof(struct utmp));
|
||||
(void)close(fd);
|
||||
if ((fd = open(_PATH_WTMP, O_WRONLY | O_APPEND, 0)) >= 0) {
|
||||
(void) write(fd, (char *) &ut, sizeof(struct utmp));
|
||||
(void) close(fd);
|
||||
}
|
||||
}
|
||||
#endif WTMP
|
||||
|
||||
#endif /* WTMP */
|
||||
|
||||
|
||||
/*
|
||||
**---------------------------------------------------------------------
|
||||
** Run-process-as-user procedures
|
||||
** Run-process-as-user procedures
|
||||
**---------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
@ -346,33 +351,36 @@ wlogin(name, req)
|
||||
#define READER_FD 0
|
||||
#define WRITER_FD 1
|
||||
|
||||
static int child_pid;
|
||||
static int child_pid;
|
||||
|
||||
static char cached_user[64] = "";
|
||||
static uid_t cached_uid;
|
||||
static gid_t cached_gid;
|
||||
static char cached_user[64] = "";
|
||||
static uid_t cached_uid;
|
||||
static gid_t cached_gid;
|
||||
|
||||
static struct sigaction old_action;
|
||||
static struct sigaction new_action;
|
||||
static struct itimerval timer;
|
||||
static struct sigaction old_action;
|
||||
static struct sigaction new_action;
|
||||
static struct itimerval timer;
|
||||
|
||||
int interrupted = 0;
|
||||
static FILE *pipe_handle;
|
||||
int interrupted = 0;
|
||||
static FILE *pipe_handle;
|
||||
|
||||
static void myhandler()
|
||||
void
|
||||
myhandler(dummy)
|
||||
int dummy;
|
||||
{
|
||||
interrupted = 1;
|
||||
fclose(pipe_handle);
|
||||
kill(child_pid, SIGKILL);
|
||||
msg_out("rpc.pcnfsd: su_popen timeout - killed child process");
|
||||
interrupted = 1;
|
||||
fclose(pipe_handle);
|
||||
kill(child_pid, SIGKILL);
|
||||
msg_out("rpc.pcnfsd: su_popen timeout - killed child process");
|
||||
}
|
||||
|
||||
void start_watchdog(n)
|
||||
int n;
|
||||
void
|
||||
start_watchdog(n)
|
||||
int n;
|
||||
{
|
||||
/*
|
||||
* Setup SIGALRM handler, force interrupt of ongoing syscall
|
||||
*/
|
||||
/*
|
||||
* Setup SIGALRM handler, force interrupt of ongoing syscall
|
||||
*/
|
||||
|
||||
new_action.sa_handler = myhandler;
|
||||
sigemptyset(&(new_action.sa_mask));
|
||||
@ -382,9 +390,9 @@ int n;
|
||||
#endif
|
||||
sigaction(SIGALRM, &new_action, &old_action);
|
||||
|
||||
/*
|
||||
* Set interval timer for n seconds
|
||||
*/
|
||||
/*
|
||||
* Set interval timer for n seconds
|
||||
*/
|
||||
timer.it_interval.tv_sec = 0;
|
||||
timer.it_interval.tv_usec = 0;
|
||||
timer.it_value.tv_sec = n;
|
||||
@ -394,11 +402,12 @@ int n;
|
||||
|
||||
}
|
||||
|
||||
void stop_watchdog()
|
||||
void
|
||||
stop_watchdog()
|
||||
{
|
||||
/*
|
||||
* Cancel timer
|
||||
*/
|
||||
/*
|
||||
* Cancel timer
|
||||
*/
|
||||
|
||||
timer.it_interval.tv_sec = 0;
|
||||
timer.it_interval.tv_usec = 0;
|
||||
@ -406,22 +415,20 @@ void stop_watchdog()
|
||||
timer.it_value.tv_usec = 0;
|
||||
setitimer(ITIMER_REAL, &timer, NULL);
|
||||
|
||||
/*
|
||||
* restore old signal handling
|
||||
*/
|
||||
/*
|
||||
* restore old signal handling
|
||||
*/
|
||||
sigaction(SIGALRM, &old_action, NULL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
FILE *
|
||||
FILE *
|
||||
su_popen(user, cmd, maxtime)
|
||||
char *user;
|
||||
char *cmd;
|
||||
int maxtime;
|
||||
char *user;
|
||||
char *cmd;
|
||||
int maxtime;
|
||||
{
|
||||
int p[2];
|
||||
int parent_fd, child_fd, pid;
|
||||
int p[2];
|
||||
int parent_fd, child_fd, pid;
|
||||
struct passwd *pw;
|
||||
|
||||
if (strcmp(cached_user, user)) {
|
||||
@ -445,7 +452,7 @@ su_popen(user, cmd, maxtime)
|
||||
parent_fd = p[READER_FD];
|
||||
child_fd = p[WRITER_FD];
|
||||
if ((pid = fork()) == 0) {
|
||||
int i;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 10; i++)
|
||||
if (i != child_fd)
|
||||
@ -477,9 +484,9 @@ su_popen(user, cmd, maxtime)
|
||||
|
||||
int
|
||||
su_pclose(ptr)
|
||||
FILE *ptr;
|
||||
FILE *ptr;
|
||||
{
|
||||
int pid, status;
|
||||
int pid, status;
|
||||
|
||||
stop_watchdog();
|
||||
|
||||
@ -490,7 +497,9 @@ su_pclose(ptr)
|
||||
return (pid == -1 ? -1 : status);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#if XXX_unused
|
||||
/*
|
||||
** The following routine reads a file "/etc/pcnfsd.conf" if present,
|
||||
** and uses it to replace certain builtin elements, like the
|
||||
@ -509,47 +518,47 @@ su_pclose(ptr)
|
||||
void
|
||||
config_from_file()
|
||||
{
|
||||
FILE *fd;
|
||||
char buff[1024];
|
||||
char *cp;
|
||||
char *kw;
|
||||
char *val;
|
||||
char *arg1;
|
||||
char *arg2;
|
||||
FILE *fd;
|
||||
char buff[1024];
|
||||
char *cp;
|
||||
char *kw;
|
||||
char *val;
|
||||
char *arg1;
|
||||
char *arg2;
|
||||
|
||||
if((fd = fopen("/etc/pcnfsd.conf", "r")) == NULL)
|
||||
if ((fd = fopen("/etc/pcnfsd.conf", "r")) == NULL)
|
||||
return;
|
||||
while(fgets(buff, 1024, fd)) {
|
||||
while (fgets(buff, 1024, fd)) {
|
||||
cp = strchr(buff, '\n');
|
||||
*cp = '\0';
|
||||
cp = strchr(buff, '#');
|
||||
if(cp)
|
||||
if (cp)
|
||||
*cp = '\0';
|
||||
kw = strtok(buff, " \t");
|
||||
if(kw == NULL)
|
||||
if (kw == NULL)
|
||||
continue;
|
||||
val = strtok(NULL, " \t");
|
||||
if(val == NULL)
|
||||
if (val == NULL)
|
||||
continue;
|
||||
if(!mystrcasecmp(kw, "spooldir")) {
|
||||
if (!strcasecmp(kw, "spooldir")) {
|
||||
strcpy(sp_name, val);
|
||||
continue;
|
||||
}
|
||||
#ifdef WTMP
|
||||
if(!mystrcasecmp(kw, "wtmp")) {
|
||||
if (!strcasecmp(kw, "wtmp")) {
|
||||
/* assume default is YES, just look for negatives */
|
||||
if(!mystrcasecmp(val, "no") ||
|
||||
!mystrcasecmp(val, "off") ||
|
||||
!mystrcasecmp(val, "disable") ||
|
||||
!strcmp(val, "0"))
|
||||
if (!strcasecmp(val, "no") ||
|
||||
!strcasecmp(val, "off") ||
|
||||
!strcasecmp(val, "disable") ||
|
||||
!strcmp(val, "0"))
|
||||
wtmp_enabled = 0;;
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
if(!mystrcasecmp(kw, "printer")) {
|
||||
#endif
|
||||
if (!strcasecmp(kw, "printer")) {
|
||||
arg1 = strtok(NULL, " \t");
|
||||
arg2 = strtok(NULL, "");
|
||||
(void)add_printer_alias(val, arg1, arg2);
|
||||
(void) add_printer_alias(val, arg1, arg2);
|
||||
continue;
|
||||
}
|
||||
/*
|
||||
@ -558,46 +567,20 @@ char *arg2;
|
||||
}
|
||||
fclose(fd);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** The following are replacements for the SunOS library
|
||||
** routines strcasecmp and strncasecmp, which SVR4 doesn't
|
||||
** include.
|
||||
*/
|
||||
|
||||
mystrcasecmp(s1, s2)
|
||||
char *s1, *s2;
|
||||
{
|
||||
|
||||
while (toupper(*s1) == toupper(*s2++))
|
||||
if (*s1++ == '\0')
|
||||
return(0);
|
||||
return(toupper(*s1) - toupper(*--s2));
|
||||
}
|
||||
|
||||
mystrncasecmp(s1, s2, n)
|
||||
char *s1, *s2;
|
||||
int n;
|
||||
{
|
||||
|
||||
while (--n >= 0 && toupper(*s1) == toupper(*s2++))
|
||||
if (*s1++ == '\0')
|
||||
return(0);
|
||||
return(n < 0 ? 0 : toupper(*s1) - toupper(*--s2));
|
||||
}
|
||||
#endif /* XXX_unused */
|
||||
|
||||
|
||||
/*
|
||||
** strembedded - returns true if s1 is embedded (in any case) in s2
|
||||
*/
|
||||
|
||||
int strembedded(s1, s2)
|
||||
char *s1;
|
||||
char *s2;
|
||||
int
|
||||
strembedded(s1, s2)
|
||||
const char *s1;
|
||||
const char *s2;
|
||||
{
|
||||
while(*s2) {
|
||||
if(!mystrcasecmp(s1, s2))
|
||||
while (*s2) {
|
||||
if (!strcasecmp(s1, s2))
|
||||
return 1;
|
||||
s2++;
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: pcnfsd_v1.c,v 1.2 1995/07/25 22:21:19 gwr Exp $ */
|
||||
/* $NetBSD: pcnfsd_v1.c,v 1.3 1997/10/25 13:45:59 lukem Exp $ */
|
||||
|
||||
/* RE_SID: @(%)/usr/dosnfs/shades_SCCS/unix/pcnfsd/v2/src/SCCS/s.pcnfsd_v1.c 1.1 91/09/03 12:41:50 SMI */
|
||||
/*
|
||||
@ -7,8 +7,6 @@
|
||||
** @(#)pcnfsd_v1.c 1.1 9/3/91
|
||||
**=====================================================================
|
||||
*/
|
||||
#include "common.h"
|
||||
|
||||
/*
|
||||
**=====================================================================
|
||||
** I N C L U D E F I L E S E C T I O N *
|
||||
@ -18,16 +16,17 @@
|
||||
** exclusion of the files conditional on this. *
|
||||
**=====================================================================
|
||||
*/
|
||||
#include "pcnfsd.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <pwd.h>
|
||||
#include <sys/file.h>
|
||||
#include <signal.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <netdb.h>
|
||||
#include <pwd.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifndef SYSV
|
||||
#include <sys/wait.h>
|
||||
@ -41,20 +40,9 @@
|
||||
#include <shadow.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
**---------------------------------------------------------------------
|
||||
** Other #define's
|
||||
**---------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
extern void scramble();
|
||||
extern char *crypt();
|
||||
|
||||
#ifdef WTMP
|
||||
extern void wlogin();
|
||||
#endif
|
||||
|
||||
extern struct passwd *get_password();
|
||||
#include "common.h"
|
||||
#include "pcnfsd.h"
|
||||
#include "extern.h"
|
||||
|
||||
/*
|
||||
**---------------------------------------------------------------------
|
||||
@ -62,7 +50,7 @@ extern struct passwd *get_password();
|
||||
**---------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
int buggit = 0;
|
||||
int buggit = 0;
|
||||
|
||||
/*
|
||||
**=====================================================================
|
||||
@ -72,91 +60,93 @@ int buggit = 0;
|
||||
|
||||
|
||||
/*ARGSUSED*/
|
||||
void *pcnfsd_null_1_svc(arg, req)
|
||||
void *arg;
|
||||
struct svc_req *req;
|
||||
void *
|
||||
pcnfsd_null_1_svc(arg, req)
|
||||
void *arg;
|
||||
struct svc_req *req;
|
||||
{
|
||||
static char dummy;
|
||||
return((void *)&dummy);
|
||||
static char dummy;
|
||||
return ((void *) &dummy);
|
||||
}
|
||||
|
||||
auth_results *pcnfsd_auth_1_svc(arg, req)
|
||||
auth_args *arg;
|
||||
struct svc_req *req;
|
||||
auth_results *
|
||||
pcnfsd_auth_1_svc(arg, req)
|
||||
auth_args *arg;
|
||||
struct svc_req *req;
|
||||
{
|
||||
static auth_results r;
|
||||
static auth_results r;
|
||||
|
||||
char uname[32];
|
||||
char pw[64];
|
||||
int c1, c2;
|
||||
struct passwd *p;
|
||||
char uname[32];
|
||||
char pw[64];
|
||||
int c1, c2;
|
||||
struct passwd *p;
|
||||
|
||||
|
||||
r.stat = AUTH_RES_FAIL; /* assume failure */
|
||||
r.uid = (int)-2;
|
||||
r.gid = (int)-2;
|
||||
r.uid = (int) -2;
|
||||
r.gid = (int) -2;
|
||||
|
||||
scramble(arg->id, uname);
|
||||
scramble(arg->pw, pw);
|
||||
|
||||
#ifdef USER_CACHE
|
||||
if(check_cache(uname, pw, &r.uid, &r.gid)) {
|
||||
r.stat = AUTH_RES_OK;
|
||||
if (check_cache(uname, pw, &r.uid, &r.gid)) {
|
||||
r.stat = AUTH_RES_OK;
|
||||
#ifdef WTMP
|
||||
wlogin(uname, req);
|
||||
#endif
|
||||
return (&r);
|
||||
}
|
||||
return (&r);
|
||||
}
|
||||
#endif
|
||||
|
||||
p = get_password(uname);
|
||||
if (p == (struct passwd *)NULL)
|
||||
return (&r);
|
||||
if (p == (struct passwd *) NULL)
|
||||
return (&r);
|
||||
|
||||
c1 = strlen(pw);
|
||||
c2 = strlen(p->pw_passwd);
|
||||
if ((c1 && !c2) || (c2 && !c1) ||
|
||||
(strcmp(p->pw_passwd, crypt(pw, p->pw_passwd))))
|
||||
{
|
||||
return (&r);
|
||||
}
|
||||
(strcmp(p->pw_passwd, crypt(pw, p->pw_passwd)))) {
|
||||
return (&r);
|
||||
}
|
||||
r.stat = AUTH_RES_OK;
|
||||
r.uid = p->pw_uid;
|
||||
r.gid = p->pw_gid;
|
||||
#ifdef WTMP
|
||||
wlogin(uname, req);
|
||||
wlogin(uname, req);
|
||||
#endif
|
||||
|
||||
#ifdef USER_CACHE
|
||||
add_cache_entry(p);
|
||||
#endif
|
||||
|
||||
return(&r);
|
||||
return (&r);
|
||||
}
|
||||
|
||||
pr_init_results *pcnfsd_pr_init_1_svc(pi_arg, req)
|
||||
pr_init_args *pi_arg;
|
||||
struct svc_req *req;
|
||||
pr_init_results *
|
||||
pcnfsd_pr_init_1_svc(pi_arg, req)
|
||||
pr_init_args *pi_arg;
|
||||
struct svc_req *req;
|
||||
{
|
||||
static pr_init_results pi_res;
|
||||
static pr_init_results pi_res;
|
||||
|
||||
pi_res.stat =
|
||||
(pirstat) pr_init(pi_arg->system, pi_arg->pn, &pi_res.dir);
|
||||
(pirstat) pr_init(pi_arg->system, pi_arg->pn, &pi_res.dir);
|
||||
|
||||
return(&pi_res);
|
||||
return (&pi_res);
|
||||
}
|
||||
|
||||
pr_start_results *pcnfsd_pr_start_1_svc(ps_arg, req)
|
||||
pr_start_args *ps_arg;
|
||||
struct svc_req *req;
|
||||
pr_start_results *
|
||||
pcnfsd_pr_start_1_svc(ps_arg, req)
|
||||
pr_start_args *ps_arg;
|
||||
struct svc_req *req;
|
||||
{
|
||||
static pr_start_results ps_res;
|
||||
char *dummyptr;
|
||||
static pr_start_results ps_res;
|
||||
char *dummyptr;
|
||||
|
||||
ps_res.stat =
|
||||
(psrstat) pr_start2(ps_arg->system, ps_arg->pn, ps_arg->user,
|
||||
ps_arg ->file, ps_arg->opts, &dummyptr);
|
||||
(psrstat) pr_start2(ps_arg->system, ps_arg->pn, ps_arg->user,
|
||||
ps_arg->file, ps_arg->opts, &dummyptr);
|
||||
|
||||
return(&ps_res);
|
||||
return (&ps_res);
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: pcnfsd_v2.c,v 1.5 1997/05/21 07:20:13 lukem Exp $ */
|
||||
/* $NetBSD: pcnfsd_v2.c,v 1.6 1997/10/25 13:46:00 lukem Exp $ */
|
||||
|
||||
/* RE_SID: @(%)/usr/dosnfs/shades_SCCS/unix/pcnfsd/v2/src/SCCS/s.pcnfsd_v2.c 1.2 91/12/18 13:26:13 SMI */
|
||||
/*
|
||||
@ -7,7 +7,6 @@
|
||||
** @(#)pcnfsd_v2.c 1.2 12/18/91
|
||||
**=====================================================================
|
||||
*/
|
||||
#include "common.h"
|
||||
/*
|
||||
**=====================================================================
|
||||
** I N C L U D E F I L E S E C T I O N *
|
||||
@ -17,17 +16,19 @@
|
||||
** exclusion of the files conditional on this. *
|
||||
**=====================================================================
|
||||
*/
|
||||
#include "pcnfsd.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <pwd.h>
|
||||
#include <grp.h>
|
||||
#include <sys/file.h>
|
||||
#include <signal.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <grp.h>
|
||||
#include <netdb.h>
|
||||
#include <pwd.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef USE_YP
|
||||
#include <rpcsvc/ypclnt.h>
|
||||
@ -45,41 +46,9 @@
|
||||
#include <shadow.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
**---------------------------------------------------------------------
|
||||
** Other #define's
|
||||
**---------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void fillin_extra_groups();
|
||||
extern void scramble();
|
||||
extern void *grab();
|
||||
extern char *crypt();
|
||||
extern int build_pr_list();
|
||||
extern pirstat build_pr_queue();
|
||||
extern psrstat pr_start();
|
||||
extern psrstat pr_start2();
|
||||
extern pcrstat pr_cancel();
|
||||
extern pirstat get_pr_status();
|
||||
|
||||
extern struct passwd *get_password();
|
||||
|
||||
#ifdef WTMP
|
||||
extern void wlogin();
|
||||
#endif
|
||||
|
||||
#ifdef USE_YP
|
||||
char *find_entry();
|
||||
#endif
|
||||
|
||||
/*
|
||||
**---------------------------------------------------------------------
|
||||
** Misc. variable definitions
|
||||
**---------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
extern pr_list printers;
|
||||
extern pr_queue queue;
|
||||
#include "common.h"
|
||||
#include "pcnfsd.h"
|
||||
#include "extern.h"
|
||||
|
||||
/*
|
||||
**=====================================================================
|
||||
@ -93,98 +62,99 @@ static char not_supported[] = "Not supported";
|
||||
static char pcnfsd_version[] = "@(#)pcnfsd_v2.c 1.2 - rpc.pcnfsd V2.0 (c) 1991 Sun Technology Enterprises, Inc.";
|
||||
|
||||
/*ARGSUSED*/
|
||||
void *pcnfsd2_null_2_svc(arg, req)
|
||||
void*arg;
|
||||
struct svc_req *req;
|
||||
void *
|
||||
pcnfsd2_null_2_svc(arg, req)
|
||||
void *arg;
|
||||
struct svc_req *req;
|
||||
{
|
||||
static char dummy;
|
||||
return((void *)&dummy);
|
||||
static char dummy;
|
||||
return ((void *) &dummy);
|
||||
}
|
||||
|
||||
v2_auth_results *pcnfsd2_auth_2_svc(arg, req)
|
||||
v2_auth_args *arg;
|
||||
struct svc_req *req;
|
||||
v2_auth_results *
|
||||
pcnfsd2_auth_2_svc(arg, req)
|
||||
v2_auth_args *arg;
|
||||
struct svc_req *req;
|
||||
{
|
||||
static v2_auth_results r;
|
||||
static v2_auth_results r;
|
||||
|
||||
char uname[32];
|
||||
char pw[64];
|
||||
int c1, c2;
|
||||
struct passwd *p;
|
||||
static u_int extra_gids[EXTRAGIDLEN];
|
||||
static char home[256];
|
||||
char uname[32];
|
||||
char pw[64];
|
||||
int c1, c2;
|
||||
struct passwd *p;
|
||||
static u_int extra_gids[EXTRAGIDLEN];
|
||||
static char home[256];
|
||||
#ifdef USE_YP
|
||||
char *yphome;
|
||||
char *cp;
|
||||
#endif /*USE_YP*/
|
||||
char *yphome;
|
||||
char *cp;
|
||||
#endif /* USE_YP */
|
||||
|
||||
|
||||
r.stat = AUTH_RES_FAIL; /* assume failure */
|
||||
r.uid = (int)-2;
|
||||
r.gid = (int)-2;
|
||||
r.uid = (int) -2;
|
||||
r.gid = (int) -2;
|
||||
r.cm = &no_comment[0];
|
||||
r.gids.gids_len = 0;
|
||||
r.gids.gids_val = &extra_gids[0];
|
||||
home[0] = '\0';
|
||||
r.home = &home[0];
|
||||
r.def_umask = umask(0);
|
||||
(void)umask(r.def_umask); /* or use 022 */
|
||||
(void) umask(r.def_umask); /* or use 022 */
|
||||
|
||||
scramble(arg->id, uname);
|
||||
scramble(arg->pw, pw);
|
||||
|
||||
#ifdef USER_CACHE
|
||||
if(check_cache(uname, pw, &r.uid, &r.gid)) {
|
||||
r.stat = AUTH_RES_OK;
|
||||
if (check_cache(uname, pw, &r.uid, &r.gid)) {
|
||||
r.stat = AUTH_RES_OK;
|
||||
#ifdef WTMP
|
||||
wlogin(uname, req);
|
||||
#endif
|
||||
fillin_extra_groups
|
||||
(uname, r.gid, &r.gids.gids_len, extra_gids);
|
||||
fillin_extra_groups
|
||||
(uname, r.gid, &r.gids.gids_len, extra_gids);
|
||||
#ifdef USE_YP
|
||||
yphome = find_entry(uname, "auto.home");
|
||||
if(yphome) {
|
||||
if (yphome) {
|
||||
strcpy(home, yphome);
|
||||
free(yphome);
|
||||
cp = strchr(home, ':');
|
||||
cp++;
|
||||
cp = strchr(cp, ':');
|
||||
if(cp)
|
||||
if (cp)
|
||||
*cp = '/';
|
||||
}
|
||||
#endif
|
||||
return (&r);
|
||||
}
|
||||
return (&r);
|
||||
}
|
||||
#endif
|
||||
|
||||
p = get_password(uname);
|
||||
if (p == (struct passwd *)NULL)
|
||||
return (&r);
|
||||
if (p == (struct passwd *) NULL)
|
||||
return (&r);
|
||||
|
||||
c1 = strlen(pw);
|
||||
c2 = strlen(p->pw_passwd);
|
||||
if ((c1 && !c2) || (c2 && !c1) ||
|
||||
(strcmp(p->pw_passwd, crypt(pw, p->pw_passwd))))
|
||||
{
|
||||
return (&r);
|
||||
}
|
||||
(strcmp(p->pw_passwd, crypt(pw, p->pw_passwd)))) {
|
||||
return (&r);
|
||||
}
|
||||
r.stat = AUTH_RES_OK;
|
||||
r.uid = p->pw_uid;
|
||||
r.gid = p->pw_gid;
|
||||
#ifdef WTMP
|
||||
wlogin(uname, req);
|
||||
#endif
|
||||
fillin_extra_groups(uname, r.gid, &r.gids.gids_len, extra_gids);
|
||||
fillin_extra_groups(uname, r.gid, &r.gids.gids_len, extra_gids);
|
||||
|
||||
#ifdef USE_YP
|
||||
yphome = find_entry(uname, "auto.home");
|
||||
if(yphome) {
|
||||
if (yphome) {
|
||||
strcpy(home, yphome);
|
||||
free(yphome);
|
||||
cp = strchr(home, ':');
|
||||
cp++;
|
||||
cp = strchr(cp, ':');
|
||||
if(cp)
|
||||
if (cp)
|
||||
*cp = '/';
|
||||
}
|
||||
#endif
|
||||
@ -193,140 +163,145 @@ char *cp;
|
||||
add_cache_entry(p);
|
||||
#endif
|
||||
|
||||
return(&r);
|
||||
return (&r);
|
||||
|
||||
}
|
||||
|
||||
v2_pr_init_results *pcnfsd2_pr_init_2_svc(arg, req)
|
||||
v2_pr_init_args *arg;
|
||||
struct svc_req *req;
|
||||
v2_pr_init_results *
|
||||
pcnfsd2_pr_init_2_svc(arg, req)
|
||||
v2_pr_init_args *arg;
|
||||
struct svc_req *req;
|
||||
{
|
||||
static v2_pr_init_results res;
|
||||
|
||||
res.stat =
|
||||
(pirstat) pr_init(arg->system, arg->pn, &res.dir);
|
||||
res.cm = &no_comment[0];
|
||||
|
||||
|
||||
return(&res);
|
||||
}
|
||||
|
||||
v2_pr_start_results *pcnfsd2_pr_start_2_svc(arg, req)
|
||||
v2_pr_start_args *arg;
|
||||
struct svc_req *req;
|
||||
{
|
||||
static v2_pr_start_results res;
|
||||
static v2_pr_init_results res;
|
||||
|
||||
res.stat =
|
||||
(psrstat) pr_start2(arg->system, arg->pn, arg->user,
|
||||
arg ->file, arg->opts, &res.id);
|
||||
(pirstat) pr_init(arg->system, arg->pn, &res.dir);
|
||||
res.cm = &no_comment[0];
|
||||
|
||||
return(&res);
|
||||
|
||||
return (&res);
|
||||
}
|
||||
|
||||
/*ARGSUSED*/
|
||||
v2_pr_list_results *pcnfsd2_pr_list_2_svc(arg, req)
|
||||
void *arg;
|
||||
struct svc_req *req;
|
||||
v2_pr_start_results *
|
||||
pcnfsd2_pr_start_2_svc(arg, req)
|
||||
v2_pr_start_args *arg;
|
||||
struct svc_req *req;
|
||||
{
|
||||
static v2_pr_list_results res;
|
||||
static v2_pr_start_results res;
|
||||
|
||||
if(printers == NULL)
|
||||
(void)build_pr_list();
|
||||
res.stat =
|
||||
(psrstat) pr_start2(arg->system, arg->pn, arg->user,
|
||||
arg->file, arg->opts, &res.id);
|
||||
res.cm = &no_comment[0];
|
||||
|
||||
return (&res);
|
||||
}
|
||||
/*ARGSUSED*/
|
||||
v2_pr_list_results *
|
||||
pcnfsd2_pr_list_2_svc(arg, req)
|
||||
void *arg;
|
||||
struct svc_req *req;
|
||||
{
|
||||
static v2_pr_list_results res;
|
||||
|
||||
if (printers == NULL)
|
||||
(void) build_pr_list();
|
||||
res.cm = &no_comment[0];
|
||||
res.printers = printers;
|
||||
|
||||
return(&res);
|
||||
return (&res);
|
||||
}
|
||||
|
||||
v2_pr_queue_results *pcnfsd2_pr_queue_2_svc(arg, req)
|
||||
v2_pr_queue_args *arg;
|
||||
struct svc_req *req;
|
||||
v2_pr_queue_results *
|
||||
pcnfsd2_pr_queue_2_svc(arg, req)
|
||||
v2_pr_queue_args *arg;
|
||||
struct svc_req *req;
|
||||
{
|
||||
static v2_pr_queue_results res;
|
||||
static v2_pr_queue_results res;
|
||||
|
||||
res.stat = build_pr_queue(arg->pn, arg->user,
|
||||
arg->just_mine, &res.qlen, &res.qshown);
|
||||
arg->just_mine, &res.qlen, &res.qshown);
|
||||
res.cm = &no_comment[0];
|
||||
res.just_yours = arg->just_mine;
|
||||
res.jobs = queue;
|
||||
|
||||
|
||||
return(&res);
|
||||
|
||||
return (&res);
|
||||
}
|
||||
|
||||
v2_pr_status_results *pcnfsd2_pr_status_2_svc(arg, req)
|
||||
v2_pr_status_args *arg;
|
||||
struct svc_req *req;
|
||||
v2_pr_status_results *
|
||||
pcnfsd2_pr_status_2_svc(arg, req)
|
||||
v2_pr_status_args *arg;
|
||||
struct svc_req *req;
|
||||
{
|
||||
static v2_pr_status_results res;
|
||||
static char status[128];
|
||||
static v2_pr_status_results res;
|
||||
static char status[128];
|
||||
|
||||
res.stat = get_pr_status(arg->pn, &res.avail, &res.printing,
|
||||
&res.qlen, &res.needs_operator, &status[0]);
|
||||
res.status = &status[0];
|
||||
&res.qlen, &res.needs_operator, &status[0]);
|
||||
res.status = &status[0];
|
||||
res.cm = &no_comment[0];
|
||||
|
||||
return(&res);
|
||||
return (&res);
|
||||
}
|
||||
|
||||
v2_pr_cancel_results *pcnfsd2_pr_cancel_2_svc(arg, req)
|
||||
v2_pr_cancel_args *arg;
|
||||
struct svc_req *req;
|
||||
v2_pr_cancel_results *
|
||||
pcnfsd2_pr_cancel_2_svc(arg, req)
|
||||
v2_pr_cancel_args *arg;
|
||||
struct svc_req *req;
|
||||
{
|
||||
static v2_pr_cancel_results res;
|
||||
static v2_pr_cancel_results res;
|
||||
|
||||
res.stat = pr_cancel(arg->pn, arg->user, arg->id);
|
||||
res.cm = &no_comment[0];
|
||||
|
||||
return(&res);
|
||||
return (&res);
|
||||
}
|
||||
|
||||
/*ARGSUSED*/
|
||||
v2_pr_requeue_results *pcnfsd2_pr_requeue_2_svc(arg, req)
|
||||
v2_pr_requeue_args *arg;
|
||||
struct svc_req *req;
|
||||
v2_pr_requeue_results *
|
||||
pcnfsd2_pr_requeue_2_svc(arg, req)
|
||||
v2_pr_requeue_args *arg;
|
||||
struct svc_req *req;
|
||||
{
|
||||
static v2_pr_requeue_results res;
|
||||
static v2_pr_requeue_results res;
|
||||
res.stat = PC_RES_FAIL;
|
||||
res.cm = ¬_supported[0];
|
||||
|
||||
return(&res);
|
||||
return (&res);
|
||||
}
|
||||
|
||||
/*ARGSUSED*/
|
||||
v2_pr_hold_results *pcnfsd2_pr_hold_2_svc(arg, req)
|
||||
v2_pr_hold_args *arg;
|
||||
struct svc_req *req;
|
||||
v2_pr_hold_results *
|
||||
pcnfsd2_pr_hold_2_svc(arg, req)
|
||||
v2_pr_hold_args *arg;
|
||||
struct svc_req *req;
|
||||
{
|
||||
static v2_pr_hold_results res;
|
||||
static v2_pr_hold_results res;
|
||||
|
||||
res.stat = PC_RES_FAIL;
|
||||
res.cm = ¬_supported[0];
|
||||
|
||||
return(&res);
|
||||
return (&res);
|
||||
}
|
||||
|
||||
/*ARGSUSED*/
|
||||
v2_pr_release_results *pcnfsd2_pr_release_2_svc(arg, req)
|
||||
v2_pr_release_args *arg;
|
||||
struct svc_req *req;
|
||||
v2_pr_release_results *
|
||||
pcnfsd2_pr_release_2_svc(arg, req)
|
||||
v2_pr_release_args *arg;
|
||||
struct svc_req *req;
|
||||
{
|
||||
static v2_pr_release_results res;
|
||||
static v2_pr_release_results res;
|
||||
|
||||
res.stat = PC_RES_FAIL;
|
||||
res.cm = ¬_supported[0];
|
||||
|
||||
return(&res);
|
||||
return (&res);
|
||||
}
|
||||
|
||||
/*ARGSUSED*/
|
||||
v2_pr_admin_results *pcnfsd2_pr_admin_2_svc(arg, req)
|
||||
v2_pr_admin_args *arg;
|
||||
struct svc_req *req;
|
||||
v2_pr_admin_results *
|
||||
pcnfsd2_pr_admin_2_svc(arg, req)
|
||||
v2_pr_admin_args *arg;
|
||||
struct svc_req *req;
|
||||
{
|
||||
static v2_pr_admin_results res;
|
||||
static v2_pr_admin_results res;
|
||||
/*
|
||||
** The default action for admin is to fail.
|
||||
** If someone wishes to implement an administration
|
||||
@ -337,75 +312,77 @@ static v2_pr_admin_results res;
|
||||
res.cm = ¬_supported[0];
|
||||
res.stat = PI_RES_FAIL;
|
||||
|
||||
return(&res);
|
||||
return (&res);
|
||||
}
|
||||
|
||||
void
|
||||
free_mapreq_results(p)
|
||||
mapreq_res p;
|
||||
mapreq_res p;
|
||||
{
|
||||
if(p->mapreq_next)
|
||||
free_mapreq_results(p->mapreq_next); /* recurse */
|
||||
if(p->name)
|
||||
(void)free(p->name);
|
||||
(void)free(p);
|
||||
if (p->mapreq_next)
|
||||
free_mapreq_results(p->mapreq_next); /* recurse */
|
||||
if (p->name)
|
||||
(void) free(p->name);
|
||||
(void) free(p);
|
||||
return;
|
||||
}
|
||||
|
||||
static char *my_strdup __P((char *));
|
||||
|
||||
static char *
|
||||
my_strdup(s)
|
||||
char *s;
|
||||
char *s;
|
||||
{
|
||||
char *r;
|
||||
r = (char *)grab(strlen(s)+1);
|
||||
char *r;
|
||||
r = (char *) grab(strlen(s) + 1);
|
||||
strcpy(r, s);
|
||||
return(r);
|
||||
return (r);
|
||||
}
|
||||
|
||||
v2_mapid_results *pcnfsd2_mapid_2_svc(arg, req)
|
||||
v2_mapid_args *arg;
|
||||
struct svc_req *req;
|
||||
v2_mapid_results *
|
||||
pcnfsd2_mapid_2_svc(arg, req)
|
||||
v2_mapid_args *arg;
|
||||
struct svc_req *req;
|
||||
{
|
||||
static v2_mapid_results res;
|
||||
struct passwd *p_passwd;
|
||||
struct group *p_group;
|
||||
static v2_mapid_results res;
|
||||
struct passwd *p_passwd;
|
||||
struct group *p_group;
|
||||
|
||||
mapreq_arg a;
|
||||
mapreq_res next_r;
|
||||
mapreq_res last_r = NULL;
|
||||
mapreq_arg a;
|
||||
mapreq_res next_r;
|
||||
mapreq_res last_r = NULL;
|
||||
|
||||
|
||||
if(res.res_list) {
|
||||
if (res.res_list) {
|
||||
free_mapreq_results(res.res_list);
|
||||
res.res_list = NULL;
|
||||
}
|
||||
|
||||
a = arg->req_list;
|
||||
while(a) {
|
||||
while (a) {
|
||||
next_r = (struct mapreq_res_item *)
|
||||
grab(sizeof(struct mapreq_res_item));
|
||||
grab(sizeof(struct mapreq_res_item));
|
||||
next_r->stat = MAP_RES_UNKNOWN;
|
||||
next_r->req = a->req;
|
||||
next_r->id = a->id;
|
||||
next_r->name = NULL;
|
||||
next_r->mapreq_next = NULL;
|
||||
|
||||
if(last_r == NULL)
|
||||
if (last_r == NULL)
|
||||
res.res_list = next_r;
|
||||
else
|
||||
last_r->mapreq_next = next_r;
|
||||
last_r = next_r;
|
||||
switch(a->req) {
|
||||
switch (a->req) {
|
||||
case MAP_REQ_UID:
|
||||
p_passwd = getpwuid((uid_t)a->id);
|
||||
if(p_passwd) {
|
||||
p_passwd = getpwuid((uid_t) a->id);
|
||||
if (p_passwd) {
|
||||
next_r->name = my_strdup(p_passwd->pw_name);
|
||||
next_r->stat = MAP_RES_OK;
|
||||
}
|
||||
break;
|
||||
case MAP_REQ_GID:
|
||||
p_group = getgrgid((gid_t)a->id);
|
||||
if(p_group) {
|
||||
p_group = getgrgid((gid_t) a->id);
|
||||
if (p_group) {
|
||||
next_r->name = my_strdup(p_group->gr_name);
|
||||
next_r->stat = MAP_RES_OK;
|
||||
}
|
||||
@ -413,7 +390,7 @@ mapreq_res last_r = NULL;
|
||||
case MAP_REQ_UNAME:
|
||||
next_r->name = my_strdup(a->name);
|
||||
p_passwd = getpwnam(a->name);
|
||||
if(p_passwd) {
|
||||
if (p_passwd) {
|
||||
next_r->id = p_passwd->pw_uid;
|
||||
next_r->stat = MAP_RES_OK;
|
||||
}
|
||||
@ -421,56 +398,57 @@ mapreq_res last_r = NULL;
|
||||
case MAP_REQ_GNAME:
|
||||
next_r->name = my_strdup(a->name);
|
||||
p_group = getgrnam(a->name);
|
||||
if(p_group) {
|
||||
if (p_group) {
|
||||
next_r->id = p_group->gr_gid;
|
||||
next_r->stat = MAP_RES_OK;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if(next_r->name == NULL)
|
||||
if (next_r->name == NULL)
|
||||
next_r->name = my_strdup("");
|
||||
a = a->mapreq_next;
|
||||
}
|
||||
|
||||
res.cm = &no_comment[0];
|
||||
|
||||
return(&res);
|
||||
return (&res);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*ARGSUSED*/
|
||||
v2_alert_results *pcnfsd2_alert_2_svc(arg, req)
|
||||
v2_alert_args *arg;
|
||||
struct svc_req *req;
|
||||
v2_alert_results *
|
||||
pcnfsd2_alert_2_svc(arg, req)
|
||||
v2_alert_args *arg;
|
||||
struct svc_req *req;
|
||||
{
|
||||
static v2_alert_results res;
|
||||
static v2_alert_results res;
|
||||
|
||||
res.stat = ALERT_RES_FAIL;
|
||||
res.cm = ¬_supported[0];
|
||||
|
||||
return(&res);
|
||||
return (&res);
|
||||
}
|
||||
|
||||
/*ARGSUSED*/
|
||||
v2_info_results *pcnfsd2_info_2_svc(arg, req)
|
||||
v2_info_args *arg;
|
||||
struct svc_req *req;
|
||||
v2_info_results *
|
||||
pcnfsd2_info_2_svc(arg, req)
|
||||
v2_info_args *arg;
|
||||
struct svc_req *req;
|
||||
{
|
||||
static v2_info_results res;
|
||||
static int facilities[FACILITIESMAX];
|
||||
static int onetime = 1;
|
||||
static v2_info_results res;
|
||||
static int facilities[FACILITIESMAX];
|
||||
static int onetime = 1;
|
||||
|
||||
#define UNSUPPORTED -1
|
||||
#define QUICK 100
|
||||
#define SLOW 2000
|
||||
|
||||
if(onetime) {
|
||||
if (onetime) {
|
||||
onetime = 0;
|
||||
facilities[PCNFSD2_NULL] = QUICK;
|
||||
facilities[PCNFSD2_INFO] = QUICK;
|
||||
facilities[PCNFSD2_PR_INIT] = QUICK;
|
||||
facilities[PCNFSD2_PR_START] = SLOW;
|
||||
facilities[PCNFSD2_PR_LIST] = QUICK; /* except first time */
|
||||
facilities[PCNFSD2_PR_LIST] = QUICK; /* except first time */
|
||||
facilities[PCNFSD2_PR_QUEUE] = SLOW;
|
||||
facilities[PCNFSD2_PR_STATUS] = SLOW;
|
||||
facilities[PCNFSD2_PR_CANCEL] = SLOW;
|
||||
@ -482,38 +460,38 @@ static int onetime = 1;
|
||||
facilities[PCNFSD2_AUTH] = QUICK;
|
||||
facilities[PCNFSD2_ALERT] = QUICK;
|
||||
}
|
||||
res.facilities.facilities_len = PCNFSD2_ALERT+1;
|
||||
res.facilities.facilities_len = PCNFSD2_ALERT + 1;
|
||||
res.facilities.facilities_val = facilities;
|
||||
|
||||
|
||||
res.vers = &pcnfsd_version[0];
|
||||
res.cm = &no_comment[0];
|
||||
|
||||
return(&res);
|
||||
return (&res);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
fillin_extra_groups(uname, main_gid, len, extra_gids)
|
||||
char *uname;
|
||||
u_int main_gid;
|
||||
int *len;
|
||||
u_int extra_gids[EXTRAGIDLEN];
|
||||
char *uname;
|
||||
gid_t main_gid;
|
||||
int *len;
|
||||
gid_t extra_gids[EXTRAGIDLEN];
|
||||
{
|
||||
struct group *grp;
|
||||
char **members;
|
||||
int n = 0;
|
||||
struct group *grp;
|
||||
char **members;
|
||||
int n = 0;
|
||||
|
||||
setgrent();
|
||||
|
||||
while(n < EXTRAGIDLEN) {
|
||||
while (n < EXTRAGIDLEN) {
|
||||
grp = getgrent();
|
||||
if(grp == NULL)
|
||||
if (grp == NULL)
|
||||
break;
|
||||
if(grp->gr_gid == main_gid)
|
||||
if (grp->gr_gid == main_gid)
|
||||
continue;
|
||||
for(members = grp->gr_mem; members && *members; members++) {
|
||||
if(!strcmp(*members, uname)) {
|
||||
for (members = grp->gr_mem; members && *members; members++) {
|
||||
if (!strcmp(*members, uname)) {
|
||||
extra_gids[n++] = grp->gr_gid;
|
||||
break;
|
||||
}
|
||||
@ -526,46 +504,43 @@ int n = 0;
|
||||
#ifdef USE_YP
|
||||
/* the following is from rpcsvc/yp_prot.h */
|
||||
#define YPMAXDOMAIN 64
|
||||
|
||||
/*
|
||||
* find_entry returns NULL on any error (printing a message) and
|
||||
* otherwise returns a pointer to the malloc'd result. The caller
|
||||
* is responsible for free()ing the result string.
|
||||
*/
|
||||
char *
|
||||
char *
|
||||
find_entry(key, map)
|
||||
char *key;
|
||||
char *map;
|
||||
char *key;
|
||||
char *map;
|
||||
{
|
||||
int err;
|
||||
char *val = NULL;
|
||||
char *cp;
|
||||
int len = 0;
|
||||
static char domain[YPMAXDOMAIN+1];
|
||||
int err;
|
||||
char *val = NULL;
|
||||
char *cp;
|
||||
int len = 0;
|
||||
static char domain[YPMAXDOMAIN + 1];
|
||||
|
||||
if(getdomainname(domain, YPMAXDOMAIN) ) {
|
||||
if (getdomainname(domain, YPMAXDOMAIN)) {
|
||||
msg_out("rpc.pcnfsd: getdomainname failed");
|
||||
return(NULL);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
if (err = yp_bind(domain)) {
|
||||
if ((err = yp_bind(domain)) != 0) {
|
||||
#ifdef DEBUG
|
||||
msg_out("rpc.pcnfsd: yp_bind failed");
|
||||
#endif
|
||||
return(NULL);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
err = yp_match(domain, map, key, strlen(key), &val, &len);
|
||||
|
||||
if (err) {
|
||||
msg_out("rpc.pcnfsd: yp_match failed");
|
||||
if (val)
|
||||
free(val);
|
||||
return(NULL);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
if(cp = strchr(val, '\n'))
|
||||
*cp = '\0'; /* in case we get an extra NL at the end */
|
||||
return(val);
|
||||
if ((cp = strchr(val, '\n')) != NULL)
|
||||
*cp = '\0'; /* in case we get an extra NL at the end */
|
||||
return (val);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user