Shadow Login Suite, release 3 patch 2
John F Haugh II
jfh at rpp386.cactus.org
Thu May 30 23:17:31 AEST 1991
Here are a number of bugs that were found, mostly by Chip Rosenthal, in
the current release of my shadow password and login suite. I am continuing
to get bug reports, and as soon as they taper off I'll send the final
result to Kent for posting in comp.sources.misc, so please beat this code
up.
The changes are of two types. The first type is to correct a number of
bugs in __STDC__ processing and whatnot, and the second makes the syslog
calls configurable. It is now possible (in theory ...) to not have
syslog involved in the resultant code. I did post a syslog thing some
time back, so you may want to look in the archives for a copy of that
code if you are determined to use syslog but didn't get one with your
system.
Chip did find a few places where the code wouldn't work (or compile) if
neither DBM nor NDBM were defined. I think those have all been caught.
I use GNU DBM here, and encourage you to do so as well. The annoying
"mkpasswd" after the BSD "chfn" and "chsh" commands has been avoided,
so if you didn't like DBM files before, you might be able to tolerate
them now. You can even use these two commands without using the rest
of the suite.
In the area of "future directions", I have purchased a set of SVR4
documentation and will start implementing commands from there. It is
good to see that AT&T/USO/BZZT are coming out with utilities for
manipulating the password files ...
--
*** rel3/Makefile Wed May 29 06:27:28 1991
--- Makefile Tue May 28 09:10:19 1991
***************
*** 1,5 ****
#
! # Copyright 1988,1989,1990, John F. Haugh II
# All rights reserved.
#
# Permission is granted to copy and create derivative works for any
--- 1,5 ----
#
! # Copyright 1988,1989,1990,1991, John F. Haugh II
# All rights reserved.
#
# Permission is granted to copy and create derivative works for any
***************
*** 8,16 ****
# and conspicuously displayed on all copies of object code or
# distribution media.
#
! # @(#)Makefile 3.8 18:25:18 - Shadow password system
#
! # @(#)Makefile 3.8 18:25:18 5/19/91
#
SHELL = /bin/sh
--- 8,16 ----
# and conspicuously displayed on all copies of object code or
# distribution media.
#
! # @(#)Makefile 3.9 09:06:23 - Shadow password system
#
! # @(#)Makefile 3.9 09:06:23 5/28/91
#
SHELL = /bin/sh
***************
*** 355,373 ****
entry.o: config.h shadow.h pwd.h
! shadow.o: shadow.h config.h
! shadowio.o: shadow.h
! grent.o: config.h shadow.h
! sgroupio.o: shadow.h
! dialup.o: dialup.h
! dialchk.o: dialup.h config.h
! pwdbm.o: config.h pwd.h
! pwpack.o: config.h pwd.h
! pwent.o: config.h pwd.h
! pwio.o: pwd.h
! getpass.o: config.h
! encrypt.o: config.h
! port.o: port.h
valid.o: config.h pwd.h
--- 355,373 ----
entry.o: config.h shadow.h pwd.h
! libshadow.a(shadow.o): shadow.h config.h
! libshadow.a(shadowio.o): shadow.h
! libshadow.a(grent.o): config.h shadow.h
! libshadow.a(sgroupio.o): shadow.h
! libshadow.a(dialup.o): dialup.h
! libshadow.a(dialchk.o): dialup.h config.h
! libshadow.a(pwdbm.o): config.h pwd.h
! libshadow.a(pwpack.o): config.h pwd.h
! libshadow.a(pwent.o): config.h pwd.h
! libshadow.a(pwio.o): pwd.h
! libshadow.a(getpass.o): config.h
! libshadow.a(encrypt.o): config.h
! libshadow.a(port.o): port.h
valid.o: config.h pwd.h
*** rel3/passwd.c Sat May 25 10:22:11 1991
--- passwd.c Tue May 28 09:10:21 1991
***************
*** 1,5 ****
/*
! * Copyright 1989, 1990, John F. Haugh II
* All rights reserved.
*
* Permission is granted to copy and create derivative works for any
--- 1,5 ----
/*
! * Copyright 1989, 1990, 1991, John F. Haugh II
* All rights reserved.
*
* Permission is granted to copy and create derivative works for any
***************
*** 14,23 ****
#include <stdio.h>
#include <fcntl.h>
#include <signal.h>
- #include <syslog.h>
#ifndef lint
! static char sccsid[] = "@(#)passwd.c 3.1 09:00:47 2/8/91";
#endif
/*
--- 14,22 ----
#include <stdio.h>
#include <fcntl.h>
#include <signal.h>
#ifndef lint
! static char sccsid[] = "@(#)passwd.c 3.2 09:06:29 5/28/91";
#endif
/*
***************
*** 40,45 ****
--- 39,52 ----
#include "lastlog.h"
#include "shadow.h"
+ #ifdef USE_SYSLOG
+ #include <syslog.h>
+
+ #ifndef LOG_WARN
+ #define LOG_WARN LOG_WARNING
+ #endif
+ #endif
+
/*
* Password aging constants
*
***************
*** 93,98 ****
--- 100,106 ----
#define NEWPASSMSG \
"Enter the new password (minimum of 5 characters)\n\
Please use a combination of upper and lower case letters and numbers.\n"
+ #define CHANGING "Changing password for %s\n"
#define NEWPASS "New Password:"
#define NEWPASS2 "Re-enter new password:"
#define WRONGPWD "Incorrect password for %s.\n"
***************
*** 172,178 ****
--- 180,188 ----
if (strcmp (cipher, sp->sp_pwdp) != 0) {
sleep (1);
fprintf (stderr, WRONGPWD, sp->sp_namp);
+ #ifdef USE_SYSLOG
syslog (LOG_WARN, WRONGPWD2, sp->sp_namp);
+ #endif
return -1;
}
strcpy (orig, clear);
***************
*** 252,258 ****
--- 262,271 ----
strcmp (sp->sp_pwdp, "!") == 0 ||
sp->sp_min > sp->sp_max) {
fprintf (stderr, CANTCHANGE, sp->sp_namp);
+ #ifdef USE_SYSLOG
syslog (LOG_WARN, CANTCHANGE2, sp->sp_namp);
+ closelog ();
+ #endif
exit (1);
}
***************
*** 262,268 ****
--- 275,284 ----
if (sp->sp_min >= 0 && now < (sp->sp_lstchg + sp->sp_min)) {
fprintf (stderr, TOOSOON, sp->sp_namp);
+ #ifdef USE_SYSLOG
syslog (LOG_WARN, TOOSOON2, sp->sp_namp);
+ closelog ();
+ #endif
exit (1);
}
}
***************
*** 435,441 ****
--- 451,459 ----
else
Prog = argv[0];
+ #ifdef USE_SYSLOG
openlog (Prog, LOG_PID|LOG_CONS|LOG_NOWAIT, LOG_AUTH);
+ #endif
/*
* Start with the flags which cause another command to be
***************
*** 463,469 ****
--- 481,490 ----
}
sprintf (buf, EXECFAILED, Prog, argv[1]);
perror (buf);
+ #ifdef USE_SYSLOG
syslog (LOG_CRIT, EXECFAILED2, argv[1]);
+ closelog ();
+ #endif
exit (1);
}
***************
*** 546,556 ****
--- 567,582 ----
if (optind < argc) {
strncpy (name, argv[optind], sizeof name);
name[sizeof name - 1] = '\0';
+ } else if (amroot) {
+ strcpy (name, "root");
} else if (cp = getlogin ()) {
strncpy (name, cp, sizeof name);
name[sizeof name - 1] = '\0';
} else {
fprintf (stderr, WHOAREYOU, Prog);
+ #ifdef USE_SYSLOG
+ closelog ();
+ #endif
exit (1);
}
***************
*** 561,575 ****
--- 587,613 ----
if (! (pw = getpwnam (name))) {
fprintf (stderr, UNKUSER, Prog, name);
+ #ifdef USE_SYSLOG
+ closelog ();
+ #endif
exit (1);
}
if (! amroot && pw->pw_uid != getuid ()) {
fprintf (stderr, NOPERM, name);
+ #ifdef USE_SYSLOG
syslog (LOG_WARN, NOPERM2, name);
+ closelog ();
+ #endif
exit (1);
}
/*
+ * Let the user know whose password is being changed.
+ */
+
+ printf (CHANGING, name);
+
+ /*
* The user name is valid, so let's get the shadow file
* entry.
*/
***************
*** 591,596 ****
--- 629,637 ----
if (Sflg) {
print_status (sp);
+ #ifdef USE_SYSLOG
+ closelog ();
+ #endif
exit (0);
}
***************
*** 609,614 ****
--- 650,658 ----
if (new_password (pw, sp)) {
fprintf (stderr, UNCHANGED, name);
+ #ifdef USE_SYSLOG
+ closelog ();
+ #endif
exit (1);
}
}
***************
*** 646,652 ****
--- 690,699 ----
ulimit (2, 30000);
if (setuid (0)) {
fprintf (stderr, NOTROOT);
+ #ifdef USE_SYSLOG
syslog (LOG_ERR, NOTROOT2);
+ closelog ();
+ #endif
exit (1);
}
signal (SIGHUP, SIG_IGN);
***************
*** 667,678 ****
--- 714,731 ----
if (i == 30) {
fprintf (stderr, SPWDBUSY);
+ #ifdef USE_SYSLOG
syslog (LOG_WARN, SPWDBUSY2);
+ closelog ();
+ #endif
exit (1);
}
if (! spw_open (O_RDWR)) {
fprintf (stderr, OPNERROR);
+ #ifdef USE_SYSLOG
syslog (LOG_ERR, OPNERROR2);
+ closelog ();
+ #endif
(void) spw_unlock ();
exit (1);
}
***************
*** 684,690 ****
--- 737,746 ----
if (! spw_update (sp)) {
fprintf (stderr, UPDERROR);
+ #ifdef USE_SYSLOG
syslog (LOG_ERR, UPDERROR2);
+ closelog ();
+ #endif
(void) spw_unlock ();
exit (1);
}
***************
*** 691,697 ****
--- 747,756 ----
#ifdef NDBM
if (access ("/etc/shadow.pag", 0) == 0 && ! sp_dbm_update (sp)) {
fprintf (stderr, DBMERROR);
+ #ifdef USE_SYSLOG
syslog (LOG_ERR, DBMERROR2);
+ closelog ();
+ #endif
(void) spw_unlock ();
exit (1);
}
***************
*** 704,718 ****
--- 763,786 ----
if (! spw_close ()) {
fprintf (stderr, CLSERROR);
+ #ifdef USE_SYSLOG
syslog (LOG_ERR, CLSERROR2);
+ closelog ();
+ #endif
(void) spw_unlock ();
exit (1);
}
if (! spw_unlock ()) {
fprintf (stderr, UNLKERROR);
+ #ifdef USE_SYSLOG
syslog (LOG_ERR, UNLKERROR2);
+ closelog ();
+ #endif
exit (1);
}
+ #ifdef USE_SYSLOG
syslog (LOG_INFO, CHGPASSWD, name);
+ closelog ();
+ #endif
exit (0);
}
*** rel3/config.h Sat May 25 10:22:07 1991
--- config.h Tue May 28 09:19:21 1991
***************
*** 1,15 ****
/*
! * Copyright 1989, 1990, John F. Haugh II
* All rights reserved.
*
! * Use, duplication, and disclosure prohibited without
! * the express written permission of the author.
*/
/*
* Configuration file for login.
*
! * @(#)config.h 3.4 14:43:20 12/18/90
*/
/*
--- 1,18 ----
/*
! * Copyright 1989, 1990, 1991, John F. Haugh II
* All rights reserved.
*
! * Permission is granted to copy and create derivative works for any
! * non-commercial purpose, provided this copyright notice is preserved
! * in all copies of source code, or included in human readable form
! * and conspicuously displayed on all copies of object code or
! * distribution media.
*/
/*
* Configuration file for login.
*
! * @(#)config.h 3.6 09:18:23 5/28/91
*/
/*
***************
*** 248,253 ****
--- 251,265 ----
#define SPWLOCK "/etc/shadow.lock"
/*
+ * Define USE_SYSLOG if you want to have SYSLOG functions included
+ * in your code. Define SULOGONLY if you only want SULOG being used
+ * in the SU command. Some people only want so much diagnostics.
+ */
+
+ #define USE_SYSLOG
+ #undef SULOGONLY
+
+ /*
* Wierd stuff follows ...
*
* The following macros exist solely to override stuff ...
***************
*** 264,269 ****
--- 276,282 ----
#define GETPWENT /* Define if you want my GETPWENT(3) routines */
#define GETGRENT /* Define if you want my GETGRENT(3) routines */
#define NEED_AL64 /* Define if library does not include a64l() */
+ #undef NO_STRSTR /* Define if library does not include strstr() */
/*
* These macros control the contents of <pwd.h>.
*** rel3/grent.c Sat May 25 10:22:53 1991
--- grent.c Tue May 28 09:10:24 1991
***************
*** 1,5 ****
/*
! * Copyright 1990, John F. Haugh II
* All rights reserved.
*
* Permission is granted to copy and create derivative works for any
--- 1,5 ----
/*
! * Copyright 1990, 1991, John F. Haugh II
* All rights reserved.
*
* Permission is granted to copy and create derivative works for any
***************
*** 32,38 ****
#endif /* NDBM */
#ifndef lint
! static char sccsid[] = "@(#)grent.c 3.7 08:03:08 12/20/90";
#endif /* !lint */
#define NFIELDS 4
--- 32,38 ----
#endif /* NDBM */
#ifndef lint
! static char sccsid[] = "@(#)grent.c 3.8 09:06:40 5/28/91";
#endif /* !lint */
#define NFIELDS 4
***************
*** 435,441 ****
}
}
#endif /* AUTOSHADOW */
! return 0;
}
/*
--- 435,441 ----
}
}
#endif /* AUTOSHADOW */
! return grp;
}
/*
*** rel3/smain.c Sat May 25 10:22:21 1991
--- smain.c Tue May 28 09:10:26 1991
***************
*** 13,19 ****
#include <stdio.h>
#ifndef lint
! static char sccsid[] = "%W% %U% %G%";
#endif
/*
--- 13,19 ----
#include <stdio.h>
#ifndef lint
! static char sccsid[] = "@(#)smain.c 3.5 09:06:44 5/28/91";
#endif
/*
***************
*** 34,45 ****
#endif
#include <signal.h>
- #include <syslog.h>
#include "config.h"
#include "lastlog.h"
#include "pwd.h"
#include "shadow.h"
/*
* Password aging constants
*
--- 34,52 ----
#endif
#include <signal.h>
#include "config.h"
#include "lastlog.h"
#include "pwd.h"
#include "shadow.h"
+ #ifdef USE_SYSLOG
+ #include <syslog.h>
+
+ #ifndef LOG_WARN
+ #define LOG_WARN LOG_WARNING
+ #endif /* !LOG_WARN */
+ #endif /* USE_SYSLOG */
+
/*
* Password aging constants
*
***************
*** 66,76 ****
#endif
#ifndef PATH
! #define PATH ":/bin:/usr/bin"
#endif
#ifndef SUPATH
! #define SUPATH ":/bin:/usr/bin:/etc"
#endif
/*
--- 73,83 ----
#endif
#ifndef PATH
! #define PATH "/bin:/usr/bin:"
#endif
#ifndef SUPATH
! #define SUPATH "/bin:/usr/bin:/etc:"
#endif
/*
***************
*** 114,119 ****
--- 121,127 ----
extern char *ttyname ();
extern char *getenv ();
extern char *getpass ();
+ extern char *pw_encrypt();
extern struct passwd *getpwuid ();
extern struct passwd *getpwnam ();
extern struct spwd *getspnam ();
***************
*** 147,153 ****
--- 155,163 ----
ioctl (0, TCGETA, &sgtty);
#endif
if (killed) {
+ #ifdef USE_SYSLOG
closelog ();
+ #endif
exit (killed);
}
}
***************
*** 191,197 ****
--- 201,209 ----
else
Prog = argv[0];
+ #ifdef USE_SYSLOG
openlog (Prog, LOG_PID|LOG_CONS|LOG_NOWAIT, LOG_AUTH);
+ #endif
/*
* Get the tty name. Entries will be logged indicating that
***************
*** 282,288 ****
--- 294,302 ----
if (pw = getpwuid (getuid ())) /* need old user name */
(void) strcpy (oldname, pw->pw_name);
else { /* user ID MUST exist */
+ #ifdef USE_SYSLOG
syslog (LOG_CRIT, "Unknown UID: %d\n", getuid ());
+ #endif
goto failure;
}
amroot = getuid () == 0; /* currently am super user */
***************
*** 302,308 ****
--- 316,324 ----
pw->pw_passwd = spwd->sp_pwdp;
} else {
(void) fprintf (stderr, "Unknown id: %s\n", name);
+ #ifdef USE_SYSLOG
closelog ();
+ #endif
exit (1);
}
pwent = *pw;
***************
*** 337,344 ****
--- 353,362 ----
if (! amroot && pwent.pw_passwd[0]) {
if (! (cp = getpass ("Password:"))) {
+ #ifdef USE_SYSLOG
syslog (pwent.pw_uid ? LOG_WARN:LOG_CRIT,
"Unable to get password for %s\n", name);
+ #endif
goto failure;
} else
strncpy (pass, cp, sizeof pass);
***************
*** 352,365 ****
--- 370,391 ----
if (! amroot && ((pass[0] != '\0' || pwent.pw_passwd[0] != '\0') &&
strcmp (pwent.pw_passwd,
pw_encrypt (pass, pwent.pw_passwd)) != 0)) {
+ #ifdef USE_SYSLOG
syslog (pwent.pw_uid ? LOG_WARN:LOG_CRIT,
"Invalid password for %s\n", name);
+ #endif
failure: sulog (0); /* log failed attempt */
+ #ifdef USE_SYSLOG
+ #ifndef SULOGONLY
syslog (pwent.pw_uid ? LOG_INFO:LOG_CRIT,
"- %s %s-%s\n", tty ? tty:"???",
oldname[0] ? oldname:"???", name[0] ? name:"???");
+ #endif
+ #endif
puts ("Sorry.");
+ #ifdef USE_SYSLOG
closelog ();
+ #endif
exit (1);
}
signal (SIGQUIT, oldsig);
***************
*** 373,380 ****
--- 399,408 ----
if (! amroot) {
if (spwd) {
if (isexpired (&pwent, spwd)) {
+ #ifdef USE_SYSLOG
syslog (pwent.pw_uid ? LOG_WARN:LOG_CRIT,
"Expired account %s\n", name);
+ #endif
goto failure;
}
}
***************
*** 381,388 ****
--- 409,418 ----
#ifdef ATT_AGE
else if (pwent.pw_age[0] &&
isexpired (&pwent, (struct spwd *) 0)) {
+ #ifdef USE_SYSLOG
syslog (pwent.pw_uid ? LOG_WARN:LOG_CRIT,
"Expired account %s\n", name);
+ #endif
goto failure;
}
#endif /* ATT_AGE */
***************
*** 405,421 ****
}
sulog (1); /* save SU information */
syslog (LOG_INFO, "+ %s %s-%s\n", tty ? tty:"???",
oldname[0] ? oldname:"???", name[0] ? name:"???");
!
if (fakelogin)
setup (&pwent); /* set UID, GID, HOME, etc ... */
else {
if (setgid (pwent.pw_gid) || setuid (pwent.pw_uid)) {
perror ("Can't set ID");
syslog (LOG_CRIT, "Unable to set uid = %d, gid = %d\n",
pwent.pw_uid, pwent.pw_gid);
closelog ();
exit (1);
}
}
--- 435,456 ----
}
sulog (1); /* save SU information */
+ #ifdef USE_SYSLOG
+ #ifndef SULOGONLY
syslog (LOG_INFO, "+ %s %s-%s\n", tty ? tty:"???",
oldname[0] ? oldname:"???", name[0] ? name:"???");
! #endif
! #endif
if (fakelogin)
setup (&pwent); /* set UID, GID, HOME, etc ... */
else {
if (setgid (pwent.pw_gid) || setuid (pwent.pw_uid)) {
perror ("Can't set ID");
+ #ifdef USE_SYSLOG
syslog (LOG_CRIT, "Unable to set uid = %d, gid = %d\n",
pwent.pw_uid, pwent.pw_gid);
closelog ();
+ #endif
exit (1);
}
}
***************
*** 425,432 ****
--- 460,469 ----
argv[-1] = pwent.pw_shell;
(void) execv (pwent.pw_shell, &argv[-1]);
(void) fprintf (stderr, "No shell\n");
+ #ifdef USE_SYSLOG
syslog (LOG_WARN, "Cannot execute %s\n", pwent.pw_shell);
closelog ();
+ #endif
exit (1);
}
if (fakelogin) {
***************
*** 450,456 ****
--- 487,497 ----
shell (pwent.pw_shell, cp);
}
+ #ifdef USE_SYSLOG
syslog (LOG_WARN, "Cannot execute %s\n", pwent.pw_shell);
+ closelog ();
+ #endif
+ exit (1);
/*NOTREACHED*/
}
*** rel3/pwconv.c Sat May 25 10:22:22 1991
--- pwconv.c Tue May 28 09:10:29 1991
***************
*** 1,5 ****
/*
! * Copyright 1989, 1990, John F. Haugh II
* All rights reserved.
*
* Permission is granted to copy and create derivative works for any
--- 1,5 ----
/*
! * Copyright 1989, 1990, 1991, John F. Haugh II
* All rights reserved.
*
* Permission is granted to copy and create derivative works for any
***************
*** 40,46 ****
#include "shadow.h"
#ifndef lint
! static char _sccsid[] = "@(#)pwconv.c 3.2 12:31:11 12/12/90";
#endif
char buf[BUFSIZ];
--- 40,46 ----
#include "shadow.h"
#ifndef lint
! static char _sccsid[] = "@(#)pwconv.c 3.3 09:06:53 5/28/91";
#endif
char buf[BUFSIZ];
***************
*** 66,72 ****
exit (1);
}
unlink ("npasswd");
! if ((fd = open ("npasswd", O_WRONLY|O_CREAT|O_EXCL, 0600)) < 0 ||
! (npwd = fdopen (fd, "w"))) {
perror ("npasswd");
exit (1);
--- 66,72 ----
exit (1);
}
unlink ("npasswd");
! if ((fd = open ("npasswd", O_WRONLY|O_CREAT|O_EXCL, 0644)) < 0 ||
! (npwd = fdopen (fd, "w"))) {
perror ("npasswd");
exit (1);
*** rel3/dialup.h Sat May 25 10:22:54 1991
--- dialup.h Tue May 28 09:10:30 1991
***************
*** 1,5 ****
/*
! * Copyright 1989, 1990, John F. Haugh II
* All rights reserved.
*
* Permission is granted to copy and create derivative works for any
--- 1,5 ----
/*
! * Copyright 1989, 1990, 1991, John F. Haugh II
* All rights reserved.
*
* Permission is granted to copy and create derivative works for any
***************
*** 23,42 ****
* lines. Each line consists of the last component of the path
* name. The leading "/dev/" string is removed.
*
! * @(#)dialup.h 3.1 19:44:22 12/10/90
*/
#ifndef _DIALUP_H
#define _DIALUP_H
- #include <stdio.h>
-
struct dialup {
char *du_shell;
char *du_passwd;
};
! #ifdef __STDC__
extern void setduent ();
extern void endduent ();
extern struct dialup *fgetduent ();
--- 23,40 ----
* lines. Each line consists of the last component of the path
* name. The leading "/dev/" string is removed.
*
! * @(#)dialup.h 3.2 09:06:55 5/28/91
*/
#ifndef _DIALUP_H
#define _DIALUP_H
struct dialup {
char *du_shell;
char *du_passwd;
};
! #if !__STDC__
extern void setduent ();
extern void endduent ();
extern struct dialup *fgetduent ();
*** rel3/chage.c Sat May 25 10:22:28 1991
--- chage.c Tue May 28 09:10:34 1991
***************
*** 1,5 ****
/*
! * Copyright 1989, 1990, John F. Haugh II
* All rights reserved.
*
* Permission is granted to copy and create derivative works for any
--- 1,5 ----
/*
! * Copyright 1989, 1990, 1991, John F. Haugh II
* All rights reserved.
*
* Permission is granted to copy and create derivative works for any
***************
*** 10,16 ****
*/
#include <sys/types.h>
- #include <syslog.h>
#include <stdio.h>
#include <fcntl.h>
#include <signal.h>
--- 10,15 ----
***************
*** 18,24 ****
#include <time.h>
#ifndef lint
! static char sccsid[] = "%W% %U% %G%";
#endif
/*
--- 17,23 ----
#include <time.h>
#ifndef lint
! static char sccsid[] = "@(#)chage.c 3.6 09:06:57 5/28/91";
#endif
/*
***************
*** 40,45 ****
--- 39,52 ----
#include "pwd.h"
#include "shadow.h"
+ #ifdef USE_SYSLOG
+ #include <syslog.h>
+
+ #ifndef LOG_WARN
+ #define LOG_WARN LOG_WARNING
+ #endif /* !LOG_WARN */
+ #endif /* USE_SYSLOG */
+
/*
* Global variables
*/
***************
*** 115,120 ****
--- 122,144 ----
[ -I inactive ] [ -E expire ] [ -d last_day ] user\n"
#define DBMERROR "Error updating the DBM password entry.\n"
#define DBMERROR2 "error updating DBM shadow entry.\n"
+ #define UNK_USER "%s: unknown user: %s\n"
+ #define NO_LFLAG "%s: do no include \"l\" with other flags\n"
+ #define NO_PERM "%s: permission denied\n"
+ #define NO_PWLOCK "%s: can't lock password file\n"
+ #define NO_SPLOCK "%s: can't lock shadow password file\n"
+ #define NO_PWOPEN "%s: can't open password file\n"
+ #define NO_SPOPEN "%s: can't open shadow password file\n"
+ #define CHANGE_INFO "Changing the aging information for %s\n"
+ #define FIELD_ERR "%s: error changing fields\n"
+ #define NO_PWUPDATE "%s: can't update password file\n"
+ #define NO_SPUPDATE "%s: can't update shadow password file\n"
+ #define NO_PWCLOSE "%s: can't rewrite password file\n"
+ #define NO_SPCLOSE "%s: can't rewrite shadow password file\n"
+ #define LOCK_FAIL "failed locking %s\n"
+ #define OPEN_FAIL "failed opening %s\n"
+ #define WRITE_FAIL "failed updating %s\n"
+ #define CLOSE_FAIL "failed rewriting %s\n"
/*
* usage - print command line syntax and exit
***************
*** 405,411 ****
--- 429,437 ----
else
Prog = argv[0];
+ #ifdef USE_SYSLOG
openlog (Prog, LOG_PID|LOG_CONS|LOG_NOWAIT, LOG_AUTH);
+ #endif
#ifdef NDBM
sp_dbm_mode = O_RDWR;
pw_dbm_mode = O_RDWR;
***************
*** 462,469 ****
usage ();
if (lflg && (mflg || Mflg || dflg || Wflg || Iflg || Eflg)) {
! fprintf (stderr, "%s: do not include \"l\" with other flags\n",
! Prog);
usage ();
}
--- 488,497 ----
usage ();
if (lflg && (mflg || Mflg || dflg || Wflg || Iflg || Eflg)) {
! fprintf (stderr, NO_LFLAG, Prog);
! #ifdef USE_SYSLOG
! closelog ();
! #endif
usage ();
}
***************
*** 474,480 ****
*/
if (ruid != 0 && ! lflg) {
! fprintf (stderr, "%s: permission denied\n", Prog);
exit (1);
}
--- 502,511 ----
*/
if (ruid != 0 && ! lflg) {
! fprintf (stderr, NO_PERM, Prog);
! #ifdef USE_SYSLOG
! closelog ();
! #endif
exit (1);
}
***************
*** 485,501 ****
*/
if (! pw_lock ()) {
! fprintf (stderr, "%s: can't lock password file\n", Prog);
exit (1);
}
if (! pw_open (ruid != 0 || lflg ? O_RDONLY:O_RDWR)) {
! fprintf (stderr, "%s: can't open password file\n", Prog);
cleanup (1);
exit (1);
}
if (! (pw = pw_locate (argv[optind]))) {
! fprintf (stderr, "%s: unknown user: %s\n", Prog, argv[optind]);
cleanup (1);
exit (1);
}
--- 516,543 ----
*/
if (! pw_lock ()) {
! fprintf (stderr, NO_PWLOCK, Prog);
! #ifdef USE_SYSLOG
! syslog (LOG_ERR, LOCK_FAIL, "/etc/passwd");
! closelog ();
! #endif
exit (1);
}
if (! pw_open (ruid != 0 || lflg ? O_RDONLY:O_RDWR)) {
! fprintf (stderr, NO_PWOPEN, Prog);
cleanup (1);
+ #ifdef USE_SYSLOG
+ syslog (LOG_ERR, OPEN_FAIL, "/etc/passwd");
+ closelog ();
+ #endif
exit (1);
}
if (! (pw = pw_locate (argv[optind]))) {
! fprintf (stderr, UNK_USER, Prog, argv[optind]);
cleanup (1);
+ #ifdef USE_SYSLOG
+ closelog ();
+ #endif
exit (1);
}
***************
*** 508,520 ****
*/
if (! spw_lock ()) {
! fprintf (stderr, "%s: can't lock shadow file\n", Prog);
cleanup (1);
exit (1);
}
if (! spw_open ((ruid != 0 || lflg) ? O_RDONLY:O_RDWR)) {
! fprintf (stderr, "%s: can't open shadow file\n", Prog);
cleanup (2);
exit (1);
}
if (sp = spw_locate (argv[optind]))
--- 550,570 ----
*/
if (! spw_lock ()) {
! fprintf (stderr, NO_SPLOCK, Prog);
cleanup (1);
+ #ifdef USE_SYSLOG
+ syslog (LOG_ERR, LOCK_FAIL, "/etc/shadow");
+ closelog ();
+ #endif
exit (1);
}
if (! spw_open ((ruid != 0 || lflg) ? O_RDONLY:O_RDWR)) {
! fprintf (stderr, NO_SPOPEN, Prog);
cleanup (2);
+ #ifdef USE_SYSLOG
+ syslog (LOG_ERR, OPEN_FAIL, "/etc/shadow");
+ closelog ();
+ #endif
exit (1);
}
if (sp = spw_locate (argv[optind]))
***************
*** 567,577 ****
if (lflg) {
if (ruid != 0 && ruid != pw->pw_uid) {
! fprintf (stderr, "%s: permission denied\n", Prog);
exit (1);
}
list_fields ();
cleanup (2);
exit (0);
}
--- 617,633 ----
if (lflg) {
if (ruid != 0 && ruid != pw->pw_uid) {
! fprintf (stderr, NO_PERM, Prog);
! #ifdef USE_SYSLOG
! closelog ();
! #endif
exit (1);
}
list_fields ();
cleanup (2);
+ #ifdef USE_SYSLOG
+ closelog ();
+ #endif
exit (0);
}
***************
*** 581,590 ****
*/
if (! mflg && ! Mflg && ! dflg && ! Wflg && ! Iflg && ! Eflg) {
! printf ("Changing the aging information for %s\n", name);
if (! new_fields ()) {
! fprintf (stderr, "%s: error changing fields\n", Prog);
cleanup (2);
exit (1);
}
}
--- 637,649 ----
*/
if (! mflg && ! Mflg && ! dflg && ! Wflg && ! Iflg && ! Eflg) {
! printf (CHANGE_INFO, name);
if (! new_fields ()) {
! fprintf (stderr, FIELD_ERR, Prog);
cleanup (2);
+ #ifdef USE_SYSLOG
+ closelog ();
+ #endif
exit (1);
}
}
***************
*** 608,616 ****
pwent.pw_age = "";
#endif
if (! pw_update (&pwent)) {
! fprintf (stderr, "%s: can't update password file\n",
! Prog);
cleanup (2);
exit (1);
}
#if defined(DBM) || defined(NDBM)
--- 667,678 ----
pwent.pw_age = "";
#endif
if (! pw_update (&pwent)) {
! fprintf (stderr, NO_PWUPDATE, Prog);
cleanup (2);
+ #ifdef USE_SYSLOG
+ syslog (LOG_ERR, WRITE_FAIL, "/etc/passwd");
+ closelog ();
+ #endif
exit (1);
}
#if defined(DBM) || defined(NDBM)
***************
*** 633,657 ****
sp->sp_expire = expdays;
if (! spw_update (sp)) {
! fprintf (stderr, "%s: can't update shadow file\n", Prog);
cleanup (2);
exit (1);
}
#ifdef NDBM
if (access ("/etc/shadow.pag", 0) == 0 && ! sp_dbm_update (sp)) {
fprintf (stderr, DBMERROR);
syslog (LOG_ERR, DBMERROR2);
! (void) spw_unlock ();
exit (1);
}
#endif /* NDBM */
if (! spw_close ()) {
! fprintf (stderr, "%s: can't rewrite shadow file\n", Prog);
cleanup (2);
exit (1);
}
- (void) pw_close ();
cleanup (2);
exit (0);
/*NOTREACHED*/
}
--- 695,758 ----
sp->sp_expire = expdays;
if (! spw_update (sp)) {
! fprintf (stderr, NO_SPUPDATE, Prog);
cleanup (2);
+ #ifdef USE_SYSLOG
+ syslog (LOG_ERR, WRITE_FAIL, "/etc/shadow");
+ closelog ();
+ #endif
exit (1);
}
#ifdef NDBM
+
+ /*
+ * See if the shadow DBM file exists and try to update it.
+ */
+
if (access ("/etc/shadow.pag", 0) == 0 && ! sp_dbm_update (sp)) {
fprintf (stderr, DBMERROR);
+ cleanup (2);
+ #ifdef USE_SYSLOG
syslog (LOG_ERR, DBMERROR2);
! closelog ();
! #endif
exit (1);
}
#endif /* NDBM */
+
+ /*
+ * Now close the shadow password file, which will cause all
+ * of the entries to be re-written.
+ */
+
if (! spw_close ()) {
! fprintf (stderr, NO_SPCLOSE, Prog);
! cleanup (2);
! #ifdef USE_SYSLOG
! syslog (LOG_ERR, CLOSE_FAIL, "/etc/shadow");
! closelog ();
! #endif
! exit (1);
! }
!
! /*
! * Close the password file. If any entries were modified, the
! * file will be re-written.
! */
!
! if (! pw_close ()) {
! fprintf (stderr, NO_PWCLOSE, Prog);
cleanup (2);
+ #ifdef USE_SYSLOG
+ syslog (LOG_ERR, CLOSE_FAIL, "/etc/passwd");
+ closelog ();
+ #endif
exit (1);
}
cleanup (2);
+ #ifdef USE_SYSLOG
+ closelog ();
+ #endif
exit (0);
/*NOTREACHED*/
}
*** rel3/chfn.c Sat May 25 10:22:19 1991
--- chfn.c Tue May 28 09:10:37 1991
***************
*** 1,5 ****
/*
! * Copyright 1989, 1990, John F. Haugh II
* All rights reserved.
*
* Permission is granted to copy and create derivative works for any
--- 1,5 ----
/*
! * Copyright 1989, 1990, 1991, John F. Haugh II
* All rights reserved.
*
* Permission is granted to copy and create derivative works for any
***************
*** 10,22 ****
*/
#include <sys/types.h>
- #include <syslog.h>
#include <stdio.h>
#include <fcntl.h>
#include <signal.h>
#ifndef lint
! static char sccsid[] = "@(#)chfn.c 3.4 11:23:40 12/19/90";
#endif
/*
--- 10,21 ----
*/
#include <sys/types.h>
#include <stdio.h>
#include <fcntl.h>
#include <signal.h>
#ifndef lint
! static char sccsid[] = "@(#)chfn.c 3.5 09:07:04 5/28/91";
#endif
/*
***************
*** 36,41 ****
--- 35,48 ----
#include "config.h"
#include "pwd.h"
+ #ifdef USE_SYSLOG
+ #include <syslog.h>
+
+ #ifndef LOG_WARN
+ #define LOG_WARN LOG_WARNING
+ #endif
+ #endif
+
/*
* Global variables.
*/
***************
*** 229,235 ****
--- 236,244 ----
else
Progname = argv[0];
+ #ifdef USE_SYSLOG
openlog (Progname, LOG_PID, LOG_AUTH);
+ #endif
/*
* The remaining arguments will be processed one by one and
***************
*** 265,270 ****
--- 274,280 ----
break;
}
fprintf (stderr, NOPERM, Progname);
+ closelog ();
exit (1);
default:
usage ();
***************
*** 285,290 ****
--- 295,301 ----
pw = getpwnam (user);
} else {
fprintf (stderr, WHOAREYOU, Progname);
+ closelog ();
exit (1);
}
***************
*** 295,300 ****
--- 306,312 ----
if (! pw) {
fprintf (stderr, UNKUSER, Progname, user);
+ closelog ();
exit (1);
}
***************
*** 306,311 ****
--- 318,324 ----
if (! amroot && pw->pw_uid != getuid ()) {
fprintf (stderr, NOPERM, Progname);
+ closelog ();
exit (1);
}
***************
*** 384,405 ****
--- 397,423 ----
if (valid_field (fullnm, ":,=")) {
fprintf (stderr, INVALID_NAME, Progname, fullnm);
+ closelog ();
exit (1);
}
if (valid_field (roomno, ":,=")) {
fprintf (stderr, INVALID_ROOM, Progname, roomno);
+ closelog ();
exit (1);
}
if (valid_field (workph, ":,=")) {
fprintf (stderr, INVALID_WORKPH, Progname, workph);
+ closelog ();
exit (1);
}
if (valid_field (homeph, ":,=")) {
fprintf (stderr, INVALID_HOMEPH, Progname, homeph);
+ closelog ();
exit (1);
}
if (valid_field (slop, ":")) {
fprintf (stderr, INVALID_OTHER, Progname, slop);
+ closelog ();
exit (1);
}
***************
*** 411,416 ****
--- 429,435 ----
if (strlen (fullnm) + strlen (roomno) + strlen (workph) +
strlen (homeph) + strlen (slop) > 80) {
fprintf (stderr, INVALID_FIELDS, Progname);
+ closelog ();
exit (1);
}
sprintf (new_gecos, "%s,%s,%s,%s", fullnm, roomno, workph, homeph);
***************
*** 431,437 ****
--- 450,459 ----
ulimit (2, 30000);
if (setuid (0)) {
fprintf (stderr, NOTROOT);
+ #ifdef USE_SYSLOG
syslog (LOG_ERR, NOTROOT2);
+ closelog ();
+ #endif
exit (1);
}
signal (SIGHUP, SIG_IGN);
***************
*** 452,464 ****
if (i == 30) {
fprintf (stderr, PWDBUSY);
syslog (LOG_WARN, PWDBUSY2);
exit (1);
}
if (! pw_open (O_RDWR)) {
fprintf (stderr, OPNERROR);
- syslog (LOG_ERR, OPNERROR2);
(void) pw_unlock ();
exit (1);
}
--- 474,492 ----
if (i == 30) {
fprintf (stderr, PWDBUSY);
+ #ifdef USE_SYSLOG
syslog (LOG_WARN, PWDBUSY2);
+ closelog ();
+ #endif
exit (1);
}
if (! pw_open (O_RDWR)) {
fprintf (stderr, OPNERROR);
(void) pw_unlock ();
+ #ifdef USE_SYSLOG
+ syslog (LOG_ERR, OPNERROR2);
+ closelog ();
+ #endif
exit (1);
}
***************
*** 469,483 ****
if (! pw_update (pw)) {
fprintf (stderr, UPDERROR);
- syslog (LOG_ERR, UPDERROR2);
(void) pw_unlock ();
exit (1);
}
#if defined(DBM) || defined(NDBM)
if (access ("/etc/passwd.pag", 0) == 0 && ! pw_dbm_update (pw)) {
fprintf (stderr, DBMERROR);
- syslog (LOG_ERR, DBMERROR2);
(void) pw_unlock ();
exit (1);
}
#endif
--- 497,517 ----
if (! pw_update (pw)) {
fprintf (stderr, UPDERROR);
(void) pw_unlock ();
+ #ifdef USE_SYSLOG
+ syslog (LOG_ERR, UPDERROR2);
+ closelog ();
+ #endif
exit (1);
}
#if defined(DBM) || defined(NDBM)
if (access ("/etc/passwd.pag", 0) == 0 && ! pw_dbm_update (pw)) {
fprintf (stderr, DBMERROR);
(void) pw_unlock ();
+ #ifdef USE_SYSLOG
+ syslog (LOG_ERR, DBMERROR2);
+ closelog ();
+ #endif
exit (1);
}
#endif
***************
*** 489,504 ****
if (! pw_close ()) {
fprintf (stderr, CLSERROR);
- syslog (LOG_ERR, CLSERROR2);
(void) pw_unlock ();
exit (1);
}
if (! pw_unlock ()) {
fprintf (stderr, UNLKERROR);
syslog (LOG_ERR, UNLKERROR2);
exit (1);
}
syslog (LOG_INFO, CHGGECOS, user);
closelog ();
exit (0);
}
--- 523,546 ----
if (! pw_close ()) {
fprintf (stderr, CLSERROR);
(void) pw_unlock ();
+ #ifdef USE_SYSLOG
+ syslog (LOG_ERR, CLSERROR2);
+ closelog ();
+ #endif
exit (1);
}
if (! pw_unlock ()) {
fprintf (stderr, UNLKERROR);
+ #ifdef USE_SYSLOG
syslog (LOG_ERR, UNLKERROR2);
+ closelog ();
+ #endif
exit (1);
}
+ #ifdef USE_SYSLOG
syslog (LOG_INFO, CHGGECOS, user);
closelog ();
+ #endif
exit (0);
}
*** rel3/chpasswd.c Sat May 25 10:22:38 1991
--- chpasswd.c Tue May 28 09:10:42 1991
***************
*** 1,5 ****
/*
! * Copyright 1990, John F. Haugh II
* All rights reserved.
*
* Permission is granted to copy and create derivative works for any
--- 1,5 ----
/*
! * Copyright 1990, 1991, John F. Haugh II
* All rights reserved.
*
* Permission is granted to copy and create derivative works for any
***************
*** 8,16 ****
* and conspicuously displayed on all copies of object code or
* distribution media.
*
! * chpass - update passwords in batch
*
! * chpass reads standard input for a list of colon separated
* user names and new passwords. the appropriate password
* files are updated to reflect the changes. because the
* changes are made in a batch fashion, the user must run
--- 8,16 ----
* and conspicuously displayed on all copies of object code or
* distribution media.
*
! * chpasswd - update passwords in batch
*
! * chpasswd reads standard input for a list of colon separated
* user names and new passwords. the appropriate password
* files are updated to reflect the changes. because the
* changes are made in a batch fashion, the user must run
***************
*** 28,34 ****
#endif
#ifndef lint
! static char sccsid[] = "@(#)chpasswd.c 3.2 12:30:30 12/12/90";
#endif
char *Prog;
--- 28,34 ----
#endif
#ifndef lint
! static char sccsid[] = "@(#)chpasswd.c 3.3 09:07:09 5/28/91";
#endif
char *Prog;
***************
*** 211,222 ****
*/
if (errors) {
! fprintf ("%s: error detected, changes ignored\n", Prog);
pw_unlock ();
exit (1);
}
if (! pw_close ()) {
! fprintf ("%s: error updating password file\n", Prog);
exit (1);
}
(void) pw_unlock ();
--- 211,222 ----
*/
if (errors) {
! fprintf (stderr, "%s: error detected, changes ignored\n", Prog);
pw_unlock ();
exit (1);
}
if (! pw_close ()) {
! fprintf (stderr, "%s: error updating password file\n", Prog);
exit (1);
}
(void) pw_unlock ();
*** rel3/chsh.c Sat May 25 10:22:20 1991
--- chsh.c Tue May 28 09:10:43 1991
***************
*** 1,5 ****
/*
! * Copyright 1989, 1990, John F. Haugh II
* All rights reserved.
*
* Permission is granted to copy and create derivative works for any
--- 1,5 ----
/*
! * Copyright 1989, 1990, 1991, John F. Haugh II
* All rights reserved.
*
* Permission is granted to copy and create derivative works for any
***************
*** 10,22 ****
*/
#include <sys/types.h>
- #include <syslog.h>
#include <stdio.h>
#include <fcntl.h>
#include <signal.h>
#ifndef lint
! static char sccsid[] = "@(#)chsh.c 3.3 11:23:29 12/19/90";
#endif
/*
--- 10,21 ----
*/
#include <sys/types.h>
#include <stdio.h>
#include <fcntl.h>
#include <signal.h>
#ifndef lint
! static char sccsid[] = "@(#)chsh.c 3.4 09:07:12 5/28/91";
#endif
/*
***************
*** 36,41 ****
--- 35,48 ----
#include "config.h"
#include "pwd.h"
+ #ifdef USE_SYSLOG
+ #include <syslog.h>
+
+ #ifndef LOG_WARN
+ #define LOG_WARN LOG_WARNING
+ #endif
+ #endif
+
/*
* Global variables.
*/
***************
*** 209,215 ****
--- 216,224 ----
else
Progname = argv[0];
+ #ifdef USE_SYSLOG
openlog (Progname, LOG_PID, LOG_AUTH);
+ #endif
/*
* There is only one option, but use getopt() anyway to
***************
*** 249,254 ****
--- 258,266 ----
pw = getpwnam (user);
} else {
fprintf (stderr, WHOAREYOU, Progname);
+ #ifdef USE_SYSLOG
+ closelog ();
+ #endif
exit (1);
}
***************
*** 259,264 ****
--- 271,279 ----
if (! pw) {
fprintf (stderr, UNKUSER, Progname, user);
+ #ifdef USE_SYSLOG
+ closelog ();
+ #endif
exit (1);
}
***************
*** 270,276 ****
--- 285,294 ----
if (! amroot && pw->pw_uid != getuid ()) {
fprintf (stderr, NOPERM, user);
+ #ifdef USE_SYSLOG
syslog (LOG_WARN, NOPERM2, user);
+ closelog ();
+ #endif
exit (1);
}
***************
*** 281,287 ****
--- 299,308 ----
if (! amroot && restricted_shell (pw->pw_shell)) {
fprintf (stderr, NOPERM, user);
+ #ifdef USE_SYSLOG
syslog (LOG_WARN, NOPERM2, user);
+ closelog ();
+ #endif
exit (1);
}
***************
*** 329,338 ****
--- 350,365 ----
if (valid_field (loginsh, ":,=")) {
fprintf (stderr, BADFIELD, Progname, loginsh);
+ #ifdef USE_SYSLOG
+ closelog ();
+ #endif
exit (1);
}
if (! check_shell (loginsh)) {
fprintf (stderr, BADSHELL, loginsh);
+ #ifdef USE_SYSLOG
+ closelog ();
+ #endif
exit (1);
}
pwent.pw_shell = loginsh;
***************
*** 348,354 ****
--- 375,384 ----
ulimit (2, 30000);
if (setuid (0)) {
fprintf (stderr, NOTROOT);
+ #ifdef USE_SYSLOG
syslog (LOG_ERR, NOTROOT2);
+ closelog ();
+ #endif
exit (1);
}
signal (SIGHUP, SIG_IGN);
***************
*** 369,381 ****
if (i == 30) {
fprintf (stderr, PWDBUSY);
syslog (LOG_WARN, PWDBUSY2);
exit (1);
}
if (! pw_open (O_RDWR)) {
fprintf (stderr, OPNERROR);
- syslog (LOG_ERR, OPNERROR2);
(void) pw_unlock ();
exit (1);
}
--- 399,417 ----
if (i == 30) {
fprintf (stderr, PWDBUSY);
+ #ifdef USE_SYSLOG
syslog (LOG_WARN, PWDBUSY2);
+ closelog ();
+ #endif
exit (1);
}
if (! pw_open (O_RDWR)) {
fprintf (stderr, OPNERROR);
(void) pw_unlock ();
+ #ifdef USE_SYSLOG
+ syslog (LOG_ERR, OPNERROR2);
+ closelog ();
+ #endif
exit (1);
}
***************
*** 386,400 ****
if (! pw_update (pw)) {
fprintf (stderr, UPDERROR);
- syslog (LOG_ERR, UPDERROR2);
(void) pw_unlock ();
exit (1);
}
#if defined(DBM) || defined(NDBM)
if (access ("/etc/passwd.pag", 0) == 0 && ! pw_dbm_update (pw)) {
fprintf (stderr, DBMERROR);
- syslog (LOG_ERR, DBMERROR2);
(void) pw_unlock ();
exit (1);
}
#endif
--- 422,442 ----
if (! pw_update (pw)) {
fprintf (stderr, UPDERROR);
(void) pw_unlock ();
+ #ifdef USE_SYSLOG
+ syslog (LOG_ERR, UPDERROR2);
+ closelog ();
+ #endif
exit (1);
}
#if defined(DBM) || defined(NDBM)
if (access ("/etc/passwd.pag", 0) == 0 && ! pw_dbm_update (pw)) {
fprintf (stderr, DBMERROR);
(void) pw_unlock ();
+ #ifdef USE_SYSLOG
+ syslog (LOG_ERR, DBMERROR2);
+ closelog ();
+ #endif
exit (1);
}
#endif
***************
*** 406,421 ****
if (! pw_close ()) {
fprintf (stderr, CLSERROR);
- syslog (LOG_ERR, CLSERROR2);
(void) pw_unlock ();
exit (1);
}
if (! pw_unlock ()) {
fprintf (stderr, UNLKERROR);
syslog (LOG_ERR, UNLKERROR2);
exit (1);
}
syslog (LOG_INFO, CHGSHELL, user, pwent.pw_shell);
closelog ();
exit (0);
}
--- 448,471 ----
if (! pw_close ()) {
fprintf (stderr, CLSERROR);
(void) pw_unlock ();
+ #ifdef USE_SYSLOG
+ syslog (LOG_ERR, CLSERROR2);
+ closelog ();
+ #endif
exit (1);
}
if (! pw_unlock ()) {
fprintf (stderr, UNLKERROR);
+ #ifdef USE_SYSLOG
syslog (LOG_ERR, UNLKERROR2);
+ closelog ();
+ #endif
exit (1);
}
+ #ifdef USE_SYSLOG
syslog (LOG_INFO, CHGSHELL, user, pwent.pw_shell);
closelog ();
+ #endif
exit (0);
}
*** rel3/entry.c Sat May 25 10:22:34 1991
--- entry.c Tue May 28 09:10:44 1991
***************
*** 1,5 ****
/*
! * Copyright 1989, 1990, John F. Haugh II
* All rights reserved.
*
* Permission is granted to copy and create derivative works for any
--- 1,5 ----
/*
! * Copyright 1989, 1990, 1991, John F. Haugh II
* All rights reserved.
*
* Permission is granted to copy and create derivative works for any
***************
*** 23,29 ****
#endif
#ifndef lint
! static char sccsid[] = "@(#)entry.c 3.2 12:30:39 12/12/90";
#endif
struct passwd *fgetpwent ();
--- 23,29 ----
#endif
#ifndef lint
! static char sccsid[] = "@(#)entry.c 3.3 09:07:17 5/28/91";
#endif
struct passwd *fgetpwent ();
***************
*** 38,43 ****
--- 38,44 ----
char *l64a ();
#endif
char *cp;
+ char *malloc();
if (! (passwd = getpwnam (name))) {
pwent->pw_name = (char *) 0;
***************
*** 57,63 ****
if (spwd = getspnam (name)) {
pwent->pw_passwd = strdup (spwd->sp_pwdp);
#ifdef ATT_AGE
! pwent->pw_age = malloc (5);
if (spwd->sp_max > (63*7))
spwd->sp_max = (63*7);
--- 58,64 ----
if (spwd = getspnam (name)) {
pwent->pw_passwd = strdup (spwd->sp_pwdp);
#ifdef ATT_AGE
! pwent->pw_age = (char *) malloc (5);
if (spwd->sp_max > (63*7))
spwd->sp_max = (63*7);
*** rel3/getpass.c Sat May 25 10:22:17 1991
--- getpass.c Tue May 28 09:10:45 1991
***************
*** 1,5 ****
/*
! * Copyright 1990, John F. Haugh II
* All rights reserved.
*
* Permission is granted to copy and create derivative works for any
--- 1,5 ----
/*
! * Copyright 1990, 1991, John F. Haugh II
* All rights reserved.
*
* Permission is granted to copy and create derivative works for any
***************
*** 22,28 ****
#endif
#ifndef lint
! static char sccsid[] = "@(#)getpass.c 3.2 08:19:03 2/5/91";
#endif
/*
--- 22,28 ----
#endif
#ifndef lint
! static char sccsid[] = "@(#)getpass.c 3.3 09:09:36 5/28/91";
#endif
/*
***************
*** 30,36 ****
* for password.
*/
! #if defined(__STDC__) || defined(_POSIX_SOURCE)
#include <limits.h>
#endif
--- 30,36 ----
* for password.
*/
! #if __STDC__ || _POSIX_SOURCE
#include <limits.h>
#endif
*** rel3/gpmain.c Sat May 25 10:22:26 1991
--- gpmain.c Tue May 28 09:10:47 1991
***************
*** 1,5 ****
/*
! * Copyright 1990, John F. Haugh II
* All rights reserved.
*
* Permission is granted to copy and create derivative works for any
--- 1,5 ----
/*
! * Copyright 1990, 1991, John F. Haugh II
* All rights reserved.
*
* Permission is granted to copy and create derivative works for any
***************
*** 38,44 ****
#endif
#ifndef lint
! static char _sccsid[] = "@(#)gpmain.c 3.4 12:30:43 12/12/90";
#endif
char name[BUFSIZ];
--- 38,44 ----
#endif
#ifndef lint
! static char _sccsid[] = "@(#)gpmain.c 3.5 09:07:24 5/28/91";
#endif
char name[BUFSIZ];
***************
*** 66,71 ****
--- 66,72 ----
extern long a64l ();
extern void entry ();
extern time_t time ();
+ extern char *malloc ();
/*
* usage - display usage message
***************
*** 156,161 ****
--- 157,163 ----
void die ();
char *cp;
char *getlogin ();
+ char *getpass ();
int amroot;
int retries;
int ruid = getuid();
*** rel3/groupio.c Sat May 25 10:22:56 1991
--- groupio.c Tue May 28 09:10:48 1991
***************
*** 1,10 ****
/*
! * Copyright 1990, John F. Haugh II
! * An unpublished work.
* All rights reserved.
*
! * Use, duplication, and disclosure prohibited without
! * the express written permission of the author.
*
* This file implements a transaction oriented group database
* library. The group file is updated one entry at a time.
--- 1,12 ----
/*
! * Copyright 1990, 1991, John F. Haugh II
* All rights reserved.
*
! * Permission is granted to copy and create derivative works for any
! * non-commercial purpose, provided this copyright notice is preserved
! * in all copies of source code, or included in human readable form
! * and conspicuously displayed on all copies of object code or
! * distribution media.
*
* This file implements a transaction oriented group database
* library. The group file is updated one entry at a time.
***************
*** 21,26 ****
--- 23,29 ----
* gr_unlock -- remove group lock
*/
+ #include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
***************
*** 33,39 ****
#endif
#ifndef lint
! static char sccsid[] = "@(#)groupio.c 3.6 15:59:12 12/9/90";
#endif
static int islocked;
--- 36,42 ----
#endif
#ifndef lint
! static char sccsid[] = "@(#)groupio.c 3.7 09:07:28 5/28/91";
#endif
static int islocked;
***************
*** 62,67 ****
--- 65,72 ----
extern char *strdup();
extern struct group *sgetgrent();
+ extern char *malloc();
+ extern char *fgetsx();
/*
* gr_dup - duplicate a group file entry
*** rel3/lmain.c Sat May 25 10:22:13 1991
--- lmain.c Tue May 28 09:10:51 1991
***************
*** 1,5 ****
/*
! * Copyright 1989, 1990, John F. Haugh II
* All rights reserved.
*
* Permission is granted to copy and create derivative works for any
--- 1,5 ----
/*
! * Copyright 1989, 1990, 1991, John F. Haugh II
* All rights reserved.
*
* Permission is granted to copy and create derivative works for any
***************
*** 16,22 ****
#include <utmp.h>
#include <time.h>
#include <signal.h>
- #include <syslog.h>
#ifndef BSD
#include <string.h>
#include <memory.h>
--- 16,21 ----
***************
*** 36,43 ****
#include "faillog.h"
#include "shadow.h"
#ifndef lint
! static char sccsid[] = "%W% %U% %G%";
#endif
#ifndef ERASECHAR
--- 35,50 ----
#include "faillog.h"
#include "shadow.h"
+ #ifdef USE_SYSLOG
+ #include <syslog.h>
+
+ #ifndef LOG_WARN
+ #define LOG_WARN LOG_WARNING
+ #endif
+ #endif
+
#ifndef lint
! static char sccsid[] = "@(#)lmain.c 3.5 09:07:32 5/28/91";
#endif
#ifndef ERASECHAR
***************
*** 258,264 ****
--- 265,273 ----
if (rflg && (hflg || fflg || pflg))
usage ();
+ #ifdef USE_SYSLOG
openlog (Prog, LOG_PID|LOG_CONS|LOG_NOWAIT, LOG_AUTH);
+ #endif
/*
* The -r and -f flags both require the real UID to be
***************
*** 266,277 ****
* flags, so the user must already be root.
*/
! if ((rflg || fflg) && getuid () != 0)
exit (1); /* only root can use -r or -f */
!
! if (! isatty (0) || ! isatty (1) || ! isatty (2))
exit (1); /* must be a terminal */
!
#ifndef BSD
(void) ioctl (0, TCGETA, &termio); /* get terminal characteristics */
--- 275,292 ----
* flags, so the user must already be root.
*/
! if ((rflg || fflg) && getuid () != 0) {
! #ifdef USE_SYSLOG
! closelog ();
! #endif
exit (1); /* only root can use -r or -f */
! }
! if (! isatty (0) || ! isatty (1) || ! isatty (2)) {
! #ifdef USE_SYSLOG
! closelog ();
! #endif
exit (1); /* must be a terminal */
! }
#ifndef BSD
(void) ioctl (0, TCGETA, &termio); /* get terminal characteristics */
***************
*** 330,338 ****
pass[0] = '\0';
if (! name[0]) { /* need to get a login id */
! if (subroot)
exit (1);
!
rflg = fflg = 0;
login (name);
continue;
--- 345,356 ----
pass[0] = '\0';
if (! name[0]) { /* need to get a login id */
! if (subroot) {
! #ifdef USE_SYSLOG
! closelog ();
! #endif
exit (1);
! }
rflg = fflg = 0;
login (name);
continue;
***************
*** 344,350 ****
--- 362,372 ----
if (pwent.pw_name) {
if (! (spwd = getspnam (name)))
+ #ifdef USE_SYSLOG
syslog (LOG_WARN, NO_SHADOW, name, tty);
+ #else
+ ;
+ #endif
else
pwent.pw_passwd = spwd->sp_pwdp;
failed = 0; /* hasn't failed validation yet */
***************
*** 374,380 ****
--- 396,404 ----
strncpy (pass, cp, sizeof pass);
if (! valid (pass, &pwent)) { /* check encrypted passwords */
+ #ifdef USE_SYSLOG
syslog (LOG_WARN, BAD_PASSWD, name, tty);
+ #endif
failed = 1;
}
bzero (pass, sizeof pass);
***************
*** 390,396 ****
--- 414,422 ----
alarm (30);
if (pwent.pw_name && ! dialcheck (tty,
pwent.pw_shell[0] ? pwent.pw_shell:"/bin/sh")) {
+ #ifdef USE_SYSLOG
syslog (LOG_WARN, BAD_DIALUP, name, tty);
+ #endif
failed = 1;
}
#endif /* DIALUP */
***************
*** 397,403 ****
--- 423,431 ----
#ifdef PORTTIME
if (pwent.pw_name &&
! isttytime (pwent.pw_name, tty, time ((time_t *) 0))) {
+ #ifdef USE_SYSLOG
syslog (LOG_WARN, BAD_TIME, name, tty);
+ #endif
failed = 1;
}
#endif /* PORTTIME */
***************
*** 420,433 ****
--- 448,465 ----
if (strcmp (CONSOLE, tty))
failed = 1;
}
+ #ifdef USE_SYSLOG
if (failed)
syslog (LOG_CRIT, BAD_ROOT_LOGIN, tty);
+ #endif
}
#endif /* CONSOLE */
#ifdef FAILLOG
if (pwent.pw_name &&
! failcheck (pwent.pw_uid, &faillog, failed)) {
+ #ifdef USE_SYSLOG
syslog (LOG_CRIT, FAILURE_CNT, name, tty);
+ #endif
failed = 1;
}
#endif /* FAILLOG */
***************
*** 435,442 ****
break;
puts ("Login incorrect");
! if (rflg || fflg)
exit (1);
#ifdef FAILLOG
if (pwent.pw_name) /* don't log non-existent users */
failure (pwent.pw_uid, tty, &faillog);
--- 467,478 ----
break;
puts ("Login incorrect");
! if (rflg || fflg) {
! #ifdef USE_SYSLOG
! closelog ();
! #endif
exit (1);
+ }
#ifdef FAILLOG
if (pwent.pw_name) /* don't log non-existent users */
failure (pwent.pw_uid, tty, &faillog);
***************
*** 458,466 ****
failtmp (&failent);
#endif /* FTMP */
! if (--retries <= 0) /* only allow so many failures */
exit (1);
!
bzero (name, sizeof name);
bzero (pass, sizeof pass);
}
--- 494,505 ----
failtmp (&failent);
#endif /* FTMP */
! if (--retries <= 0) { /* only allow so many failures */
! #ifdef USE_SYSLOG
! closelog ();
! #endif
exit (1);
! }
bzero (name, sizeof name);
bzero (pass, sizeof pass);
}
***************
*** 488,493 ****
--- 527,535 ----
} else
printf ("\r\nSystem closed for routine maintenance\n");
+ #ifdef USE_SYSLOG
+ closelog ();
+ #endif
exit (0);
}
#endif /* NOLOGINS */
***************
*** 567,575 ****
--- 609,620 ----
endspent (); /* stop access to shadow passwd file */
endsgent (); /* stop access to shadow group file */
+ #ifdef USE_SYSLOG
if (pwent.pw_uid == 0)
syslog (LOG_INFO, ROOT_LOGIN, tty);
+ closelog ();
+ #endif
shell (pwent.pw_shell, (char *) 0); /* exec the shell finally. */
/*NOTREACHED*/
}
*** rel3/mkpasswd.c Sat May 25 10:22:14 1991
--- mkpasswd.c Tue May 28 09:10:54 1991
***************
*** 1,5 ****
/*
! * Copyright 1990, John F. Haugh II
* All rights reserved.
*
* Permission is granted to copy and create derivative works for any
--- 1,5 ----
/*
! * Copyright 1990, 1991, John F. Haugh II
* All rights reserved.
*
* Permission is granted to copy and create derivative works for any
***************
*** 9,16 ****
--- 9,35 ----
* distribution media.
*/
+ #ifndef lint
+ static char sccsid[] = "@(#)mkpasswd.c 3.5 09:07:38 5/28/91";
+ static char copyright[] = "Copyright 1990, 1991, John F. Haugh II";
+ #endif
+
#include "config.h"
#include <stdio.h>
+
+ #if !defined(DBM) && !defined(NDBM) /*{*/
+
+ main (argc, argv)
+ int argc;
+ char **argv;
+ {
+ fprintf(stderr, "%s: no DBM database on system - no action performed\n",
+ argv[0]);
+ exit(0);
+ }
+
+ #else /*} defined(DBM) || defined(NDBM) {*/
+
#include <fcntl.h>
#include "pwd.h"
#ifdef BSD
***************
*** 39,49 ****
DBM *sgr_dbm;
#endif
- #ifndef lint
- static char sccsid[] = "@(#)mkpasswd.c 3.4 11:29:08 12/19/90";
- static char copyright[] = "Copyright 1990, John F. Haugh II";
- #endif
-
char *CANT_OPEN = "%s: cannot open file %s\n";
char *CANT_OVERWRITE = "%s: cannot overwrite file %s\n";
char *CANT_CREATE = "%s: cannot create %s\n";
--- 58,63 ----
***************
*** 378,380 ****
--- 392,395 ----
exit (1);
/*NOTREACHED*/
}
+ #endif /*} defined(DBM) || defined(NDBM) */
*** rel3/newgrp.c Sat May 25 10:22:05 1991
--- newgrp.c Tue May 28 09:10:56 1991
***************
*** 1,5 ****
/*
! * Copyright 1990, John F. Haugh II
* All rights reserved.
*
* Permission is granted to copy and create derivative works for any
--- 1,5 ----
/*
! * Copyright 1990, 1991, John F. Haugh II
* All rights reserved.
*
* Permission is granted to copy and create derivative works for any
***************
*** 21,27 ****
#include "config.h"
#ifndef lint
! static char sccsid[] = "@(#)newgrp.c 3.3 12:30:58 12/12/90";
#endif
#ifdef NGROUPS
--- 21,27 ----
#include "config.h"
#ifndef lint
! static char sccsid[] = "@(#)newgrp.c 3.4 09:07:42 5/28/91";
#endif
#ifdef NGROUPS
***************
*** 44,49 ****
--- 44,52 ----
char *getlogin();
char *crypt();
+ char *getpass();
+ char *getenv();
+ char *pw_encrypt();
void shell();
char *name;
*** rel3/newusers.c Sat May 25 10:22:40 1991
--- newusers.c Tue May 28 09:10:58 1991
***************
*** 1,5 ****
/*
! * Copyright 1990, John F. Haugh II
* All rights reserved.
*
* Permission is granted to copy and create derivative works for any
--- 1,5 ----
/*
! * Copyright 1990, 1991, John F. Haugh II
* All rights reserved.
*
* Permission is granted to copy and create derivative works for any
***************
*** 26,32 ****
#endif
#ifndef lint
! static char sccsid[] = "@(#)newusers.c 3.2 12:31:02 12/12/90";
#endif
char *Prog;
--- 26,32 ----
#endif
#ifndef lint
! static char sccsid[] = "@(#)newusers.c 3.3 09:07:46 5/28/91";
#endif
char *Prog;
***************
*** 273,278 ****
--- 273,279 ----
struct passwd *pw;
struct passwd pwent;
static char newage[5];
+ extern char *l64a();
/*
* In the case of regular password files, this is real
***************
*** 581,587 ****
*/
if (errors) {
! fprintf ("%s: error detected, changes ignored\n", Prog);
(void) gr_unlock ();
#ifdef SHADOWPWD
(void) spw_unlock ();
--- 582,588 ----
*/
if (errors) {
! fprintf (stderr, "%s: error detected, changes ignored\n", Prog);
(void) gr_unlock ();
#ifdef SHADOWPWD
(void) spw_unlock ();
***************
*** 595,601 ****
if (! pw_close () || ! gr_close ())
#endif
{
! fprintf ("%s: error updating files\n", Prog);
(void) gr_unlock ();
#ifdef SHADOWPWD
(void) spw_unlock ();
--- 596,602 ----
if (! pw_close () || ! gr_close ())
#endif
{
! fprintf (stderr, "%s: error updating files\n", Prog);
(void) gr_unlock ();
#ifdef SHADOWPWD
(void) spw_unlock ();
*** rel3/obscure.c Sat May 25 10:22:08 1991
--- obscure.c Tue May 28 09:11:00 1991
***************
*** 1,5 ****
/*
! * Copyright 1989, 1990, John F. Haugh II
* All rights reserved.
*
* Permission is granted to copy and create derivative works for any
--- 1,5 ----
/*
! * Copyright 1989, 1990, 1991, John F. Haugh II
* All rights reserved.
*
* Permission is granted to copy and create derivative works for any
***************
*** 21,27 ****
#include "config.h"
#ifndef lint
! static char sccsid[] = "@(#)obscure.c 3.1 11:31:35 12/19/90";
#endif
/*
--- 21,52 ----
#include "config.h"
#ifndef lint
! static char sccsid[] = "@(#)obscure.c 3.2 09:07:51 5/28/91";
! #endif
!
! #ifdef NO_STRSTR
! /*
! * strstr - find substring in string
! */
!
! char *
! strstr (string, pattern)
! char *string;
! char *pattern;
! {
! char *cp;
! int len;
!
! len = strlen (pattern);
!
! for (cp = string;cp = strchr (cp, *pattern);) {
! if (strncmp (cp, pattern, len) == 0)
! return cp;
!
! cp++;
! }
! return 0;
! }
#endif
/*
*** rel3/pwd.h Sat May 25 10:22:50 1991
--- pwd.h Tue May 28 09:11:01 1991
***************
*** 1,5 ****
/*
! * Copyright 1990, John F. Haugh II and Steve Simmons
* All rights reserved.
*
* Permission is granted to copy and create derivative works for any
--- 1,5 ----
/*
! * Copyright 1990, 1991, John F. Haugh II and Steve Simmons
* All rights reserved.
*
* Permission is granted to copy and create derivative works for any
***************
*** 27,33 ****
#ifndef PWD_H
#define PWD_H
! #include <sys/types.h>
/*
* For now these are defined here. Later they should be moved to
--- 27,36 ----
#ifndef PWD_H
#define PWD_H
! #ifdef M_XENIX
! typedef int uid_t;
! typedef int gid_t;
! #endif
/*
* For now these are defined here. Later they should be moved to
***************
*** 77,83 ****
};
#endif
! #ifdef __STDC__
extern struct passwd *getpwent( void ) ;
extern struct passwd *getpwuid( uid_t user_uid ) ;
--- 80,86 ----
};
#endif
! #if __STDC__
extern struct passwd *getpwent( void ) ;
extern struct passwd *getpwuid( uid_t user_uid ) ;
***************
*** 93,98 ****
int setpwent();
int endpwent();
! #endif /* of ifdef __STDC__ */
#endif /* of ifdef PWD_H */
--- 96,101 ----
int setpwent();
int endpwent();
! #endif /* of if __STDC__ */
#endif /* of ifdef PWD_H */
*** rel3/pwdbm.c Sat May 25 10:22:42 1991
--- pwdbm.c Tue May 28 09:11:02 1991
***************
*** 1,5 ****
/*
! * Copyright 1990, John F. Haugh II
* All rights reserved.
*
* Permission is granted to copy and create derivative works for any
--- 1,5 ----
/*
! * Copyright 1990, 1991, John F. Haugh II
* All rights reserved.
*
* Permission is granted to copy and create derivative works for any
***************
*** 10,16 ****
*/
#ifndef lint
! static char sccsid[] = "@(#)pwdbm.c 3.3 12:31:13 12/12/90";
#endif
#ifdef BSD
--- 10,16 ----
*/
#ifndef lint
! static char sccsid[] = "@(#)pwdbm.c 3.4 09:08:00 5/28/91";
#endif
#ifdef BSD
***************
*** 24,29 ****
--- 24,31 ----
#include "pwd.h"
#include "config.h"
+ #if defined(DBM) || defined(NDBM) /*{*/
+
#ifdef DBM
#include <dbm.h>
#endif
***************
*** 94,96 ****
--- 96,100 ----
#endif
return 1;
}
+
+ #endif /*} defined(NDBM) || defined(DBM) */
*** rel3/pwio.c Sat May 25 10:22:37 1991
--- pwio.c Tue May 28 09:11:05 1991
***************
*** 1,5 ****
/*
! * Copyright 1990, John F. Haugh II
* All rights reserved.
*
* Permission is granted to copy and create derivative works for any
--- 1,5 ----
/*
! * Copyright 1990, 1991, John F. Haugh II
* All rights reserved.
*
* Permission is granted to copy and create derivative works for any
***************
*** 23,28 ****
--- 23,29 ----
* pw_unlock -- remove password lock
*/
+ #include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
***************
*** 29,36 ****
#include "pwd.h"
#include <stdio.h>
#ifndef lint
! static char sccsid[] = "@(#)pwio.c 3.6 12:31:19 12/12/90";
#endif
static int islocked;
--- 30,43 ----
#include "pwd.h"
#include <stdio.h>
+ #ifdef BSD
+ # include <strings.h>
+ #else
+ # include <string.h>
+ #endif
+
#ifndef lint
! static char sccsid[] = "@(#)pwio.c 3.7 09:08:02 5/28/91";
#endif
static int islocked;
***************
*** 58,63 ****
--- 65,71 ----
static char pw_filename[BUFSIZ] = PASSWD;
extern char *strdup();
+ extern char *malloc();
extern struct passwd *sgetpwent();
/*
*** rel3/pwunconv.c Sat May 25 10:22:07 1991
--- pwunconv.c Tue May 28 09:11:07 1991
***************
*** 1,5 ****
/*
! * Copyright 1989, 1990, John F. Haugh II
* All rights reserved.
*
* Permission is granted to copy and create derivative works for any
--- 1,5 ----
/*
! * Copyright 1989, 1990, 1991, John F. Haugh II
* All rights reserved.
*
* Permission is granted to copy and create derivative works for any
***************
*** 27,33 ****
#include "shadow.h"
#ifndef lint
! static char sccsid[] = "@(#)pwunconv.c 3.2 12:31:26 12/12/90";
#endif
#ifdef ITI_AGING
--- 27,33 ----
#include "shadow.h"
#ifndef lint
! static char sccsid[] = "@(#)pwunconv.c 3.3 09:08:06 5/28/91";
#endif
#ifdef ITI_AGING
***************
*** 108,114 ****
pw->pw_age = "";
#endif /* ATT_AGE */
if (putpwent (pw, npwd)) {
! perror (stderr, "pwunconv: write error");
exit (1);
}
}
--- 108,114 ----
pw->pw_age = "";
#endif /* ATT_AGE */
if (putpwent (pw, npwd)) {
! perror ("pwunconv: write error");
exit (1);
}
}
*** rel3/setup.c Sat May 25 10:22:34 1991
--- setup.c Tue May 28 09:11:08 1991
***************
*** 12,18 ****
#include <sys/types.h>
#include <stdio.h>
#include <utmp.h>
- #include <syslog.h>
#ifdef BSD
#include <strings.h>
--- 12,17 ----
***************
*** 25,32 ****
#include "config.h"
#include "pwd.h"
#ifndef lint
! static char sccsid[] = "@(#)setup.c 3.3 07:46:41 2/6/91";
#endif
#ifndef PATH
--- 24,39 ----
#include "config.h"
#include "pwd.h"
+ #ifdef USE_SYSLOG
+ #include <syslog.h>
+
+ #ifndef LOG_WARN
+ #define LOG_WARN LOG_WARNING
+ #endif
+ #endif
+
#ifndef lint
! static char sccsid[] = "@(#)setup.c 3.4 09:08:08 5/28/91";
#endif
#ifndef PATH
***************
*** 87,94 ****
--- 94,104 ----
(void) strcat (strcpy (tty, "/dev/"), utent.ut_line);
if (chown (tty, info->pw_uid, info->pw_gid) || chmod (tty, TTYPERM)) {
(void) sprintf (buf, "Unable to change tty %s", tty);
+ #ifdef USE_SYSLOG
syslog (LOG_WARN, "unable to change tty `%s' for user `%s'",
tty, info->pw_name);
+ closelog ();
+ #endif
perror (buf);
exit (errno);
}
***************
*** 95,102 ****
--- 105,115 ----
#endif
if (chdir (info->pw_dir) == -1) {
(void) sprintf (buf, "Unable to cd to \"%s\"", info->pw_dir);
+ #ifdef USE_SYSLOG
syslog (LOG_WARN, "unable to cd to `%s' for user `%s'",
info->pw_dir, info->pw_name);
+ closelog ();
+ #endif
perror (buf);
exit (errno);
}
***************
*** 130,137 ****
--- 143,153 ----
#endif
if (setgid (info->pw_gid) == -1) {
puts ("Bad group id");
+ #ifdef USE_SYSLOG
syslog (LOG_WARN, "bad group ID `%d' for user `%s'",
info->pw_gid, info->pw_name);
+ closelog ();
+ #endif
exit (errno);
}
#ifndef BSD
***************
*** 141,148 ****
--- 157,167 ----
#endif
{
puts ("Bad user id");
+ #ifdef USE_SYSLOG
syslog (LOG_WARN, "bad user ID `%d' for user `%s'",
info->pw_uid, info->pw_name);
+ closelog ();
+ #endif
exit (errno);
}
(void) strcat (strcpy (buf, "HOME="), info->pw_dir);
*** rel3/sgroupio.c Sat May 25 10:22:59 1991
--- sgroupio.c Tue May 28 09:11:11 1991
***************
*** 1,5 ****
/*
! * Copyright 1990, John F. Haugh II
* All rights reserved.
*
* Permission is granted to copy and create derivative works for any
--- 1,5 ----
/*
! * Copyright 1990, 1991, John F. Haugh II
* All rights reserved.
*
* Permission is granted to copy and create derivative works for any
***************
*** 23,28 ****
--- 23,29 ----
* sgr_unlock -- remove shadow group lock
*/
+ #include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
***************
*** 37,43 ****
#include "shadow.h"
#ifndef lint
! static char sccsid[] = "@(#)sgroupio.c 3.1 08:13:51 12/14/90";
#endif
static int islocked;
--- 38,44 ----
#include "shadow.h"
#ifndef lint
! static char sccsid[] = "@(#)sgroupio.c 3.2 09:08:11 5/28/91";
#endif
static int islocked;
***************
*** 67,72 ****
--- 68,74 ----
extern char *strdup();
extern struct sgrp *sgetgsent();
extern char *fgetsx();
+ extern char *malloc();
/*
* sgr_dup - duplicate a shadow group file entry
*** rel3/shadowio.c Sat May 25 10:22:58 1991
--- shadowio.c Tue May 28 09:11:16 1991
***************
*** 1,9 ****
/*
! * Copyright 1990, John F. Haugh II
* All rights reserved.
*
! * Use, duplication, and disclosure prohibited without
! * the express written permission of the author.
*
* This file implements a transaction oriented password database
* library. The password file is updated one entry at a time.
--- 1,12 ----
/*
! * Copyright 1990, 1991, John F. Haugh II
* All rights reserved.
*
! * Permission is granted to copy and create derivative works for any
! * non-commercial purpose, provided this copyright notice is preserved
! * in all copies of source code, or included in human readable form
! * and conspicuously displayed on all copies of object code or
! * distribution media.
*
* This file implements a transaction oriented password database
* library. The password file is updated one entry at a time.
***************
*** 21,29 ****
*/
#ifndef lint
! static char sccsid[] = "@(#)shadowio.c 3.4 07:54:20 12/1/90";
#endif
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
--- 24,33 ----
*/
#ifndef lint
! static char sccsid[] = "@(#)shadowio.c 3.5 09:08:15 5/28/91";
#endif
+ #include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
***************
*** 60,65 ****
--- 64,70 ----
static char spw_filename[BUFSIZ] = SHADOW;
extern char *strdup();
+ extern char *malloc();
extern struct spwd *sgetspent();
/*
*** rel3/sub.c Sat May 25 10:22:48 1991
--- sub.c Tue May 28 09:11:18 1991
***************
*** 1,5 ****
/*
! * Copyright 1989, 1990, John F. Haugh II
* All rights reserved.
*
* Permission is granted to copy and create derivative works for any
--- 1,5 ----
/*
! * Copyright 1989, 1990, 1991, John F. Haugh II
* All rights reserved.
*
* Permission is granted to copy and create derivative works for any
***************
*** 10,21 ****
*/
#include <sys/types.h>
#include <syslog.h>
#include "pwd.h"
#ifndef lint
! static char sccsid[] = "@(#)sub.c 3.2 08:22:12 1/30/91";
#endif
#define BAD_SUBROOT "Invalid root directory \"%s\"\n"
--- 10,29 ----
*/
#include <sys/types.h>
+ #include "config.h"
+
+ #ifdef USE_SYSLOG
#include <syslog.h>
+ #ifndef LOG_WARN
+ #define LOG_WARN LOG_WARNING
+ #endif
+ #endif
+
#include "pwd.h"
#ifndef lint
! static char sccsid[] = "@(#)sub.c 3.3 09:08:19 5/28/91";
#endif
#define BAD_SUBROOT "Invalid root directory \"%s\"\n"
***************
*** 41,47 ****
--- 49,58 ----
if (pw->pw_dir[0] != '/') {
printf (BAD_SUBROOT, pw->pw_dir);
+ #ifdef USE_SYSLOG
syslog (LOG_WARN, BAD_SUBROOT2, pw->pw_dir, pw->pw_name);
+ closelog ();
+ #endif
exit (1);
}
***************
*** 52,58 ****
--- 63,72 ----
if (chdir (pw->pw_dir) || chroot (pw->pw_dir)) {
printf (NO_SUBROOT, pw->pw_dir);
+ #ifdef USE_SYSLOG
syslog (LOG_WARN, NO_SUBROOT2, pw->pw_dir, pw->pw_name);
+ closelog ();
+ #endif
exit (1);
}
}
*** rel3/sulogin.c Sat May 25 10:22:15 1991
--- sulogin.c Tue May 28 09:11:18 1991
***************
*** 1,5 ****
/*
! * Copyright 1989, 1990, John F. Haugh II
* All rights reserved.
*
* Permission is granted to copy and create derivative works for any
--- 1,5 ----
/*
! * Copyright 1989, 1990, 1991, John F. Haugh II
* All rights reserved.
*
* Permission is granted to copy and create derivative works for any
***************
*** 24,30 ****
#include "config.h"
#ifndef lint
! static char sccsid[] = "@(#)sulogin.c 3.3 12:31:35 12/12/90";
#endif
char name[BUFSIZ];
--- 24,30 ----
#include "config.h"
#ifndef lint
! static char sccsid[] = "@(#)sulogin.c 3.4 09:08:21 5/28/91";
#endif
char name[BUFSIZ];
***************
*** 65,70 ****
--- 65,71 ----
{
char *getenv ();
char *ttyname ();
+ char *getpass ();
char *cp;
if (access (PWDFILE, 0) == -1) { /* must be a password file! */
*** rel3/utmp.c Sat May 25 10:22:23 1991
--- utmp.c Tue May 28 09:11:19 1991
***************
*** 1,5 ****
/*
! * Copyright 1989, 1990, John F. Haugh II
* All rights reserved.
*
* Permission is granted to copy and create derivative works for any
--- 1,5 ----
/*
! * Copyright 1989, 1990, 1991, John F. Haugh II
* All rights reserved.
*
* Permission is granted to copy and create derivative works for any
***************
*** 25,31 ****
#include "config.h"
#ifndef lint
! static char sccsid[] = "%W% %U% %G%";
#endif
extern struct utmp utent;
--- 25,31 ----
#include "config.h"
#ifndef lint
! static char sccsid[] = "@(#)utmp.c 3.4 09:08:23 5/28/91";
#endif
extern struct utmp utent;
***************
*** 138,144 ****
close (fd);
if ((wtmp = fopen (WTMP_FILE, "a+"))) {
! fwrite (&utent, sizeof utent, 1, wtmp);
fclose (wtmp);
}
}
--- 138,144 ----
close (fd);
if ((wtmp = fopen (WTMP_FILE, "a+"))) {
! fwrite ((char *) &utent, sizeof utent, 1, wtmp);
fclose (wtmp);
}
}
*** rel3/chage.c Tue May 28 09:14:40 1991
--- chage.c Wed May 29 06:35:11 1991
***************
*** 17,23 ****
#include <time.h>
#ifndef lint
! static char sccsid[] = "@(#)chage.c 3.6 09:06:57 5/28/91";
#endif
/*
--- 17,23 ----
#include <time.h>
#ifndef lint
! static char sccsid[] = "@(#)chage.c 3.7 06:35:00 5/29/91";
#endif
/*
***************
*** 320,326 ****
*/
printf ("Last Change:\t\t");
! if (changed <= 0) {
printf ("Never\n");
} else {
changed = lastday * SCALE;
--- 320,326 ----
*/
printf ("Last Change:\t\t");
! if (lastday <= 0) {
printf ("Never\n");
} else {
changed = lastday * SCALE;
***************
*** 336,342 ****
*/
printf ("Password Expires:\t");
! if (changed <= 0 || maxdays >= 10000*(DAY/SCALE) || maxdays <= 0) {
printf ("Never\n");
} else {
expires = changed + maxdays * SCALE;
--- 336,342 ----
*/
printf ("Password Expires:\t");
! if (lastday <= 0 || maxdays >= 10000*(DAY/SCALE) || maxdays <= 0) {
printf ("Never\n");
} else {
expires = changed + maxdays * SCALE;
***************
*** 353,359 ****
*/
printf ("Password Inactive:\t");
! if (changed <= 0 || inactdays <= 0 ||
maxdays >= 10000*(DAY/SCALE) || maxdays <= 0) {
printf ("Never\n");
} else {
--- 353,359 ----
*/
printf ("Password Inactive:\t");
! if (lastday <= 0 || inactdays <= 0 ||
maxdays >= 10000*(DAY/SCALE) || maxdays <= 0) {
printf ("Never\n");
} else {
--
John F. Haugh II | Distribution to | UUCP: ...!cs.utexas.edu!rpp386!jfh
Ma Bell: (512) 255-8251 | GEnie PROHIBITED :-) | Domain: jfh at rpp386.cactus.org
"If liberals interpreted the 2nd Amendment the same way they interpret the
rest of the Constitution, gun ownership would be mandatory."
More information about the Alt.sources
mailing list