[svn-upgrade] Integrating new upstream version, shadow (4.0.1)

This commit is contained in:
nekral-guest
2007-10-07 11:44:59 +00:00
parent 3bc4996775
commit 9db6abfa42
194 changed files with 20217 additions and 14460 deletions

View File

@@ -36,6 +36,7 @@ libmisc_la_SOURCES = \
mail.c \
motd.c \
myname.c \
nscd.c \
obscure.c \
pam_pass.c \
pwd2spwd.c \
@@ -57,3 +58,5 @@ libmisc_la_SOURCES = \
utmp.c \
valid.c \
xmalloc.c
libmisc_la_LIBADD = $(LIBCRACK)

View File

@@ -144,6 +144,7 @@ libmisc_la_SOURCES = \
mail.c \
motd.c \
myname.c \
nscd.c \
obscure.c \
pam_pass.c \
pwd2spwd.c \
@@ -166,6 +167,8 @@ libmisc_la_SOURCES = \
valid.c \
xmalloc.c
libmisc_la_LIBADD = $(LIBCRACK)
subdir = libmisc
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = $(top_builddir)/config.h
@@ -173,16 +176,16 @@ CONFIG_CLEAN_FILES =
LTLIBRARIES = $(lib_LTLIBRARIES)
libmisc_la_LDFLAGS =
libmisc_la_LIBADD =
libmisc_la_DEPENDENCIES =
am_libmisc_la_OBJECTS = addgrps.lo age.lo basename.lo chkname.lo \
chkshell.lo chowndir.lo chowntty.lo console.lo copydir.lo \
entry.lo env.lo failure.lo fields.lo getdate.lo hushed.lo \
isexpired.lo limits.lo list.lo log.lo login_access.lo \
login_desrpc.lo login_krb.lo loginprompt.lo mail.lo motd.lo \
myname.lo obscure.lo pam_pass.lo pwd2spwd.lo pwdcheck.lo \
pwd_init.lo rlogin.lo salt.lo setugid.lo setup.lo setupenv.lo \
shell.lo strtoday.lo suauth.lo sub.lo sulog.lo ttytype.lo tz.lo \
ulimit.lo utmp.lo valid.lo xmalloc.lo
myname.lo nscd.lo obscure.lo pam_pass.lo pwd2spwd.lo \
pwdcheck.lo pwd_init.lo rlogin.lo salt.lo setugid.lo setup.lo \
setupenv.lo shell.lo strtoday.lo suauth.lo sub.lo sulog.lo \
ttytype.lo tz.lo ulimit.lo utmp.lo valid.lo xmalloc.lo
libmisc_la_OBJECTS = $(am_libmisc_la_OBJECTS)
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
CPPFLAGS = @CPPFLAGS@
@@ -202,17 +205,17 @@ depcomp = $(SHELL) $(top_srcdir)/depcomp
@AMDEP_TRUE@ $(DEPDIR)/login_desrpc.Plo $(DEPDIR)/login_krb.Plo \
@AMDEP_TRUE@ $(DEPDIR)/loginprompt.Plo $(DEPDIR)/mail.Plo \
@AMDEP_TRUE@ $(DEPDIR)/motd.Plo $(DEPDIR)/myname.Plo \
@AMDEP_TRUE@ $(DEPDIR)/obscure.Plo $(DEPDIR)/pam_pass.Plo \
@AMDEP_TRUE@ $(DEPDIR)/pwd2spwd.Plo $(DEPDIR)/pwd_init.Plo \
@AMDEP_TRUE@ $(DEPDIR)/pwdcheck.Plo $(DEPDIR)/rlogin.Plo \
@AMDEP_TRUE@ $(DEPDIR)/salt.Plo $(DEPDIR)/setugid.Plo \
@AMDEP_TRUE@ $(DEPDIR)/setup.Plo $(DEPDIR)/setupenv.Plo \
@AMDEP_TRUE@ $(DEPDIR)/shell.Plo $(DEPDIR)/strtoday.Plo \
@AMDEP_TRUE@ $(DEPDIR)/suauth.Plo $(DEPDIR)/sub.Plo \
@AMDEP_TRUE@ $(DEPDIR)/sulog.Plo $(DEPDIR)/ttytype.Plo \
@AMDEP_TRUE@ $(DEPDIR)/tz.Plo $(DEPDIR)/ulimit.Plo \
@AMDEP_TRUE@ $(DEPDIR)/utmp.Plo $(DEPDIR)/valid.Plo \
@AMDEP_TRUE@ $(DEPDIR)/xmalloc.Plo
@AMDEP_TRUE@ $(DEPDIR)/nscd.Plo $(DEPDIR)/obscure.Plo \
@AMDEP_TRUE@ $(DEPDIR)/pam_pass.Plo $(DEPDIR)/pwd2spwd.Plo \
@AMDEP_TRUE@ $(DEPDIR)/pwd_init.Plo $(DEPDIR)/pwdcheck.Plo \
@AMDEP_TRUE@ $(DEPDIR)/rlogin.Plo $(DEPDIR)/salt.Plo \
@AMDEP_TRUE@ $(DEPDIR)/setugid.Plo $(DEPDIR)/setup.Plo \
@AMDEP_TRUE@ $(DEPDIR)/setupenv.Plo $(DEPDIR)/shell.Plo \
@AMDEP_TRUE@ $(DEPDIR)/strtoday.Plo $(DEPDIR)/suauth.Plo \
@AMDEP_TRUE@ $(DEPDIR)/sub.Plo $(DEPDIR)/sulog.Plo \
@AMDEP_TRUE@ $(DEPDIR)/ttytype.Plo $(DEPDIR)/tz.Plo \
@AMDEP_TRUE@ $(DEPDIR)/ulimit.Plo $(DEPDIR)/utmp.Plo \
@AMDEP_TRUE@ $(DEPDIR)/valid.Plo $(DEPDIR)/xmalloc.Plo
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) \
@@ -301,6 +304,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/mail.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/motd.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/myname.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/nscd.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/obscure.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/pam_pass.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/pwd2spwd.Plo@am__quote@

View File

@@ -37,26 +37,11 @@
#include "defines.h"
#include <pwd.h>
#include <grp.h>
#ifdef HAVE_USERSEC_H
#include <userpw.h>
#include <usersec.h>
#include <userconf.h>
#endif
#ifndef AGING
#if defined(SHADOWPWD) || defined(HAVE_USERSEC_H)
#define AGING 1
#endif
#else
#if !defined(SHADOWPWD) && !defined(HAVE_USERSEC_H) && !defined(ATT_AGE)
#undef AGING
#endif
#endif
#if defined(SHADOWPWD) || defined(AGING) /*{*/
#if defined(SHADOWPWD)
#include "rcsid.h"
RCSID("$Id: age.c,v 1.6 1998/12/28 20:34:42 marekm Exp $")
RCSID("$Id: age.c,v 1.7 2001/12/22 06:59:30 kloczek Exp $")
#ifndef PASSWD_PROGRAM
#define PASSWD_PROGRAM "/bin/passwd"
@@ -69,34 +54,22 @@ RCSID("$Id: age.c,v 1.6 1998/12/28 20:34:42 marekm Exp $")
* if it has expired.
*/
#ifdef SHADOWPWD
int
expire(const struct passwd *pw, const struct spwd *sp)
{
#else
int
expire(const struct passwd *pw)
{
#endif
int status;
int child;
int pid;
#ifdef SHADOWPWD
if (! sp)
sp = pwd_to_spwd (pw);
#endif
/*
* See if the user's password has expired, and if so
* force them to change their password.
*/
#ifdef SHADOWPWD
switch (status = isexpired (pw, sp))
#else
switch (status = isexpired (pw))
#endif
{
case 0:
return 0;
@@ -118,11 +91,7 @@ expire(const struct passwd *pw)
* change that password.
*/
#ifdef SHADOWPWD
if (status > 1 || sp->sp_max < sp->sp_min)
#else
if (status > 1 || c64i (pw->pw_age[0]) < c64i (pw->pw_age[1]))
#endif
{
puts(_(" Contact the system administrator.\n"));
exit(1);
@@ -136,13 +105,9 @@ expire(const struct passwd *pw)
* might become stale after "passwd" is executed.
*/
#ifdef SHADOWPWD
endspent ();
#endif
endpwent ();
#ifdef SHADOWGRP
endsgent ();
#endif
endgrent ();
/*
@@ -188,19 +153,12 @@ expire(const struct passwd *pw)
* to expire and warns the user of the pending password expiration.
*/
#ifdef SHADOWPWD
void
agecheck(const struct passwd *pw, const struct spwd *sp)
{
#else
void
agecheck(const struct passwd *pw)
{
#endif
long now = time ((long *) 0) / SCALE;
long remain;
#ifdef SHADOWPWD
if (! sp)
sp = pwd_to_spwd (pw);
@@ -211,17 +169,7 @@ agecheck(const struct passwd *pw)
if (sp->sp_lstchg == -1 || sp->sp_max == -1 || sp->sp_warn == -1)
return;
#else
if (pw->pw_age[0] == '\0')
return;
#endif
#ifdef SHADOWPWD
if ((remain = (sp->sp_lstchg + sp->sp_max) - now) <= sp->sp_warn)
#else
if ((remain = (a64l (pw->pw_age + 2) + c64i (pw->pw_age[0])) * 7
- now) <= getdef_num ("PASS_WARN_AGE", 7))
#endif
{
remain /= DAY/SCALE;
if (remain > 1)
@@ -232,4 +180,4 @@ agecheck(const struct passwd *pw)
printf(_("Your password will expire today.\n"));
}
}
#endif /*}*/
#endif /* SHADOWPWD */

View File

@@ -6,7 +6,7 @@
#include <config.h>
#include "rcsid.h"
RCSID("$Id: chkname.c,v 1.4 1998/04/16 19:57:43 marekm Exp $")
RCSID("$Id: chkname.c,v 1.5 2001/11/17 01:24:57 kloczek Exp $")
#include <ctype.h>
#include "defines.h"
@@ -22,19 +22,16 @@ static int
good_name(const char *name)
{
/*
* User/group names must start with a letter, and may not
* contain colons, commas, newlines (used in passwd/group
* files...) or any non-printable characters.
* User/group names must match [a-z_][a-z0-9_-]*
*/
if (!*name || !isalpha(*name))
if (!*name || !((*name >= 'a' && *name <= 'z') || *name == '_'))
return 0;
while (*name) {
if (*name == ':' || *name == ',' ||
*name == '\n' || !isprint(*name))
while (*++name) {
if (!((*name >= 'a' && *name <= 'z') ||
(*name >= '0' && *name <= '9') ||
*name == '_' || *name == '-'))
return 0;
name++;
}
return 1;

View File

@@ -39,27 +39,9 @@
#include "defines.h"
#include <pwd.h>
#include <time.h>
#ifdef HAVE_USERSEC_H
#include <userpw.h>
#include <usersec.h>
#include <userconf.h>
#endif
#ifndef AGING
#if defined(SHADOWPWD) || defined(HAVE_USERSEC_H)
#define AGING 1
#endif
#else
#if !defined(SHADOWPWD) && !defined(HAVE_USERSEC_H) && !defined(ATT_AGE)
#undef AGING
#endif
#endif
#if defined(SHADOWPWD) || defined(AGING) /*{*/
#include "rcsid.h"
RCSID("$Id: isexpired.c,v 1.7 1997/12/07 23:27:05 marekm Exp $")
RCSID("$Id: isexpired.c,v 1.9 2002/01/06 14:02:39 kloczek Exp $")
/*
* isexpired - determine if account is expired yet
@@ -74,23 +56,9 @@ RCSID("$Id: isexpired.c,v 1.7 1997/12/07 23:27:05 marekm Exp $")
int
isexpired(const struct passwd *pw, const struct spwd *sp)
{
#else
int
isexpired(const struct passwd *pw)
{
#endif
long now;
#ifdef HAVE_USERSEC_H
int minage = 0;
int maxage = 10000;
int curage = 0;
struct userpw *pu;
#endif
now = time ((time_t *) 0) / SCALE;
#ifdef SHADOWPWD
if (!sp)
sp = pwd_to_spwd(pw);
@@ -117,25 +85,6 @@ isexpired(const struct passwd *pw)
if (sp->sp_lstchg > 0 && sp->sp_max >= 0 && sp->sp_inact >= 0 &&
now >= sp->sp_lstchg + sp->sp_max + sp->sp_inact)
return 2;
#endif
#ifdef HAVE_USERSEC_H /*{*/
/*
* The aging information lives someplace else. Get it from the
* login.cfg file
*/
if (getconfattr (SC_SYS_PASSWD, SC_MINAGE, &minage, SEC_INT))
minage = -1;
if (getconfattr (SC_SYS_PASSWD, SC_MAXAGE, &maxage, SEC_INT))
maxage = -1;
pu = getuserpw (pw->pw_name);
curage = (time (0) - pu->upw_lastupdate) / (7*86400L);
if (maxage != -1 && curage > maxage)
return 1;
#else /*} !HAVE_USERSEC_H */
/*
* The last and max fields must be present for an account
@@ -143,11 +92,9 @@ isexpired(const struct passwd *pw)
* is considered to be infinite.
*/
#ifdef SHADOWPWD
if (sp->sp_lstchg == -1 ||
sp->sp_max == -1 || sp->sp_max >= (10000L*DAY/SCALE))
return 0;
#endif
#ifdef ATT_AGE
if (pw->pw_age[0] == '\0' || pw->pw_age[0] == '/')
return 0;
@@ -159,15 +106,12 @@ isexpired(const struct passwd *pw)
* the password has expired.
*/
#ifdef SHADOWPWD
if (now >= sp->sp_lstchg + sp->sp_max)
return 1;
#endif
#ifdef ATT_AGE
if (a64l (pw->pw_age + 2) + c64i (pw->pw_age[1]) < now / 7)
return 1;
#endif
#endif /*} HAVE_USERSEC_H */
return 0;
}
#endif /*}*/
#endif /* SHADOWPWD */

95
libmisc/nscd.c Normal file
View File

@@ -0,0 +1,95 @@
/* Copyright (c) 1999 SuSE GmbH Nuerenberg, Germany
Author: Thorsten Kukuk <kukuk@suse.de> */
#include <assert.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/socket.h>
#include <sys/un.h>
/* Version number of the daemon interface */
#define NSCD_VERSION 2
/* Path for the Unix domain socket. */
#define _PATH_NSCDSOCKET "/var/run/.nscd_socket"
/* Available services. */
typedef enum
{
GETPWBYNAME,
GETPWBYUID,
GETGRBYNAME,
GETGRBYGID,
GETHOSTBYNAME,
GETHOSTBYNAMEv6,
GETHOSTBYADDR,
GETHOSTBYADDRv6,
LASTDBREQ = GETHOSTBYADDRv6,
SHUTDOWN, /* Shut the server down. */
GETSTAT, /* Get the server statistic. */
INVALIDATE, /* Invalidate one special cache. */
LASTREQ
} request_type;
/* Header common to all requests */
typedef struct
{
int version; /* Version number of the daemon interface. */
request_type type; /* Service requested. */
#if defined(__alpha__)
int64_t key_len; /* Key length is 64bit on Alpha. */
#else
int32_t key_len; /* Key length, 32bit on most plattforms. */
#endif
} request_header;
/* Create a socket connected to a name. */
static int
nscd_open_socket (void)
{
struct sockaddr_un addr;
int sock;
sock = socket (PF_UNIX, SOCK_STREAM, 0);
if (sock < 0)
return -1;
addr.sun_family = AF_UNIX;
assert (sizeof (addr.sun_path) >= sizeof (_PATH_NSCDSOCKET));
strcpy (addr.sun_path, _PATH_NSCDSOCKET);
if (connect (sock, (struct sockaddr *) &addr, sizeof (addr)) < 0)
{
close (sock);
return -1;
}
return sock;
}
int
nscd_flush_cache (char *service)
{
int sock = nscd_open_socket ();
request_header req;
ssize_t nbytes;
if (sock == -1)
return -1;
req.version = NSCD_VERSION;
req.type = INVALIDATE;
req.key_len = strlen (service) + 1;
nbytes = write (sock, &req, sizeof (request_header));
if (nbytes != sizeof (request_header))
{
close (sock);
return -1;
}
nbytes = write (sock, (void *)service, req.key_len);
close (sock);
return (nbytes != req.key_len ? (-1) : 0);
}

View File

@@ -34,7 +34,7 @@
#include <config.h>
#include "rcsid.h"
RCSID("$Id: setupenv.c,v 1.10 2000/08/26 18:27:17 marekm Exp $")
RCSID("$Id: setupenv.c,v 1.11 2001/11/06 15:50:25 kloczek Exp $")
#include <sys/types.h>
#include <sys/stat.h>
@@ -59,6 +59,7 @@ addenv_path(const char *varname, const char *dirname, const char *filename)
}
#ifndef USE_PAM
static void
read_env_file(const char *filename)
{
@@ -176,6 +177,8 @@ finished:
}
fclose(fp);
}
#endif /* USE_PAM */
/*
* change to the user's home directory
@@ -186,7 +189,10 @@ finished:
void
setup_env(struct passwd *info)
{
char *cp, *envf;
#ifndef USE_PAM
char *envf;
#endif
char *cp;
/*
* Change the current working directory to be the home directory

View File

@@ -41,7 +41,7 @@
#include <stdio.h>
#include "rcsid.h"
RCSID("$Id: utmp.c,v 1.8 1999/06/07 16:40:44 marekm Exp $")
RCSID("$Id: utmp.c,v 1.9 2001/11/06 16:18:08 kloczek Exp $")
#if HAVE_UTMPX_H
extern struct utmpx utxent;
@@ -52,9 +52,6 @@ extern struct utmp *getutent();
extern struct utmp *getutline();
extern void setutent();
extern void endutent();
extern time_t time();
extern char *ttyname();
extern long lseek();
#define NO_UTENT \
"No utmp entry. You must exec \"login\" from the lowest level \"sh\""