[svn-upgrade] Integrating new upstream version, shadow (4.0.12)
This commit is contained in:
@@ -13,6 +13,7 @@ libshadow_la_SOURCES = \
|
||||
commonio.h \
|
||||
defines.h \
|
||||
encrypt.c \
|
||||
exitcodes.h \
|
||||
faillog.h \
|
||||
fputsx.c \
|
||||
getdef.c \
|
||||
@@ -49,5 +50,4 @@ libshadow_la_SOURCES = \
|
||||
|
||||
EXTRA_DIST = \
|
||||
.indent.pro \
|
||||
grpack.c gspack.c pwpack.c sppack.c \
|
||||
gshadow_.h
|
||||
|
@@ -208,6 +208,7 @@ libshadow_la_SOURCES = \
|
||||
commonio.h \
|
||||
defines.h \
|
||||
encrypt.c \
|
||||
exitcodes.h \
|
||||
faillog.h \
|
||||
fputsx.c \
|
||||
getdef.c \
|
||||
@@ -244,7 +245,6 @@ libshadow_la_SOURCES = \
|
||||
# sources for dbm support (not yet used)
|
||||
EXTRA_DIST = \
|
||||
.indent.pro \
|
||||
grpack.c gspack.c pwpack.c sppack.c \
|
||||
gshadow_.h
|
||||
|
||||
all: all-am
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/* $Id: defines.h,v 1.26 2005/05/25 18:20:22 kloczek Exp $ */
|
||||
/* $Id: defines.h,v 1.27 2005/08/03 18:11:27 kloczek Exp $ */
|
||||
/* some useful defines */
|
||||
|
||||
#ifndef _DEFINES_H_
|
||||
@@ -24,6 +24,8 @@
|
||||
# undef textdomain
|
||||
# define textdomain(Domain) /* empty */
|
||||
# define _(Text) Text
|
||||
# define ngettext(Msgid1, Msgid2, N) \
|
||||
((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
|
||||
#endif
|
||||
|
||||
#if STDC_HEADERS
|
||||
|
9
lib/exitcodes.h
Normal file
9
lib/exitcodes.h
Normal file
@@ -0,0 +1,9 @@
|
||||
/* $Id: exitcodes.h,v 1.3 2005/07/27 10:10:31 kloczek Exp $ */
|
||||
|
||||
/*
|
||||
* Exit codes used by shadow programs
|
||||
*/
|
||||
#define E_SUCCESS 0 /* success */
|
||||
#define E_NOPERM 1 /* permission denied */
|
||||
#define E_USAGE 2 /* invalid command syntax */
|
||||
#define E_BAD_ARG 3 /* invalid argument to option */
|
60
lib/getdef.c
60
lib/getdef.c
@@ -30,7 +30,7 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID ("$Id: getdef.c,v 1.31 2005/07/12 18:54:39 kloczek Exp $")
|
||||
RCSID ("$Id: getdef.c,v 1.35 2005/08/11 11:26:11 kloczek Exp $")
|
||||
#include "prototypes.h"
|
||||
#include "defines.h"
|
||||
#include <stdio.h>
|
||||
@@ -48,22 +48,43 @@ struct itemdef {
|
||||
#define NUMDEFS (sizeof(def_table)/sizeof(def_table[0]))
|
||||
static struct itemdef def_table[] = {
|
||||
{"CHFN_RESTRICT", NULL},
|
||||
{"CONSOLE_GROUPS", NULL},
|
||||
{"CONSOLE", NULL},
|
||||
{"CREATE_HOME", NULL},
|
||||
{"DEFAULT_HOME", NULL},
|
||||
{"ENV_PATH", NULL},
|
||||
{"ENV_SUPATH", NULL},
|
||||
{"ERASECHAR", NULL},
|
||||
{"FAIL_DELAY", NULL},
|
||||
{"FAKE_SHELL", NULL},
|
||||
{"GETPASS_ASTERISKS", NULL},
|
||||
{"GID_MAX", NULL},
|
||||
{"GID_MIN", NULL},
|
||||
{"HUSHLOGIN_FILE", NULL},
|
||||
{"KILLCHAR", NULL},
|
||||
{"LOGIN_RETRIES", NULL},
|
||||
{"LOGIN_TIMEOUT", NULL},
|
||||
{"LOG_OK_LOGINS", NULL},
|
||||
{"LOG_UNKFAIL_ENAB", NULL},
|
||||
{"MAIL_DIR", NULL},
|
||||
{"PASS_MAX_DAYS", NULL},
|
||||
{"PASS_MIN_DAYS", NULL},
|
||||
{"PASS_WARN_AGE", NULL},
|
||||
{"SULOG_FILE", NULL},
|
||||
{"SU_NAME", NULL},
|
||||
{"TTYGROUP", NULL},
|
||||
{"TTYPERM", NULL},
|
||||
{"TTYTYPE_FILE", NULL},
|
||||
{"UID_MAX", NULL},
|
||||
{"UID_MIN", NULL},
|
||||
{"UMASK", NULL},
|
||||
{"USERDEL_CMD", NULL},
|
||||
#ifdef USE_PAM
|
||||
{"CLOSE_SESSIONS", NULL},
|
||||
#else
|
||||
{"USERGROUPS_ENAB", NULL},
|
||||
#ifndef USE_PAM
|
||||
{"CHFN_AUTH", NULL},
|
||||
{"CHSH_AUTH", NULL},
|
||||
{"CRACKLIB_DICTPATH", NULL},
|
||||
{"ENV_HZ", NULL},
|
||||
{"ENV_PATH", NULL},
|
||||
{"ENV_ROOTPATH", NULL}, /* SuSE compatibility? */
|
||||
{"ENV_SUPATH", NULL},
|
||||
{"ENV_TZ", NULL},
|
||||
{"ENVIRON_FILE", NULL},
|
||||
{"FAILLOG_ENAB", NULL},
|
||||
@@ -83,38 +104,13 @@ static struct itemdef def_table[] = {
|
||||
{"PASS_MIN_LEN", NULL},
|
||||
{"PORTTIME_CHECKS_ENAB", NULL},
|
||||
{"SU_WHEEL_ONLY", NULL},
|
||||
{"QMAIL_DIR", NULL},
|
||||
{"QUOTAS_ENAB", NULL},
|
||||
{"ULIMIT", NULL},
|
||||
#endif
|
||||
{"CONSOLE_GROUPS", NULL},
|
||||
{"CONSOLE", NULL},
|
||||
{"CREATE_HOME", NULL},
|
||||
{"ERASECHAR", NULL},
|
||||
{"FAKE_SHELL", NULL},
|
||||
{"GETPASS_ASTERISKS", NULL},
|
||||
{"GID_MAX", NULL},
|
||||
{"GID_MIN", NULL},
|
||||
{"HUSHLOGIN_FILE", NULL},
|
||||
{"KILLCHAR", NULL},
|
||||
{"LOGIN_RETRIES", NULL},
|
||||
{"LOGIN_TIMEOUT", NULL},
|
||||
{"LOG_OK_LOGINS", NULL},
|
||||
{"LOG_UNKFAIL_ENAB", NULL},
|
||||
{"MAIL_DIR", NULL},
|
||||
{"SULOG_FILE", NULL},
|
||||
{"SU_NAME", NULL},
|
||||
#ifdef USE_SYSLOG
|
||||
{"SYSLOG_SG_ENAB", NULL},
|
||||
{"SYSLOG_SU_ENAB", NULL},
|
||||
#endif
|
||||
{"TTYGROUP", NULL},
|
||||
{"TTYPERM", NULL},
|
||||
{"TTYTYPE_FILE", NULL},
|
||||
{"UID_MAX", NULL},
|
||||
{"UID_MIN", NULL},
|
||||
{"UMASK", NULL},
|
||||
{"USERGROUPS_ENAB", NULL},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
|
90
lib/grpack.c
90
lib/grpack.c
@@ -1,90 +0,0 @@
|
||||
/*
|
||||
* Copyright 1990, Julianne Frances Haugh
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of Julianne F. Haugh nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY JULIE HAUGH AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL JULIE HAUGH OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID ("$Id: grpack.c,v 1.4 2005/03/31 05:14:49 kloczek Exp $")
|
||||
#include <stdio.h>
|
||||
#include <grp.h>
|
||||
#include "defines.h"
|
||||
int gr_pack (const struct group *group, char *buf)
|
||||
{
|
||||
char *cp;
|
||||
int i;
|
||||
|
||||
cp = buf;
|
||||
strcpy (cp, group->gr_name);
|
||||
cp += strlen (cp) + 1;
|
||||
|
||||
strcpy (cp, group->gr_passwd);
|
||||
cp += strlen (cp) + 1;
|
||||
|
||||
memcpy (cp, (const char *) &group->gr_gid, sizeof group->gr_gid);
|
||||
cp += sizeof group->gr_gid;
|
||||
|
||||
for (i = 0; group->gr_mem[i]; i++) {
|
||||
strcpy (cp, group->gr_mem[i]);
|
||||
cp += strlen (cp) + 1;
|
||||
}
|
||||
*cp++ = '\0';
|
||||
|
||||
return cp - buf;
|
||||
}
|
||||
|
||||
int gr_unpack (char *buf, int len, struct group *group)
|
||||
{
|
||||
char *org = buf;
|
||||
int i;
|
||||
|
||||
group->gr_name = buf;
|
||||
buf += strlen (buf) + 1;
|
||||
if (buf - org > len)
|
||||
return -1;
|
||||
|
||||
group->gr_passwd = buf;
|
||||
buf += strlen (buf) + 1;
|
||||
if (buf - org > len)
|
||||
return -1;
|
||||
|
||||
memcpy ((char *) &group->gr_gid, (char *) buf, sizeof group->gr_gid);
|
||||
buf += sizeof group->gr_gid;
|
||||
if (buf - org > len)
|
||||
return -1;
|
||||
|
||||
for (i = 0; *buf && i < 1024; i++) {
|
||||
group->gr_mem[i] = buf;
|
||||
buf += strlen (buf) + 1;
|
||||
|
||||
if (buf - org > len)
|
||||
return -1;
|
||||
}
|
||||
group->gr_mem[i] = (char *) 0;
|
||||
return 0;
|
||||
}
|
145
lib/gspack.c
145
lib/gspack.c
@@ -1,145 +0,0 @@
|
||||
/*
|
||||
* Copyright 1990 - 1994, Julianne Frances Haugh
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of Julianne F. Haugh nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY JULIE HAUGH AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL JULIE HAUGH OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#ifdef SHADOWGRP /*{ */
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID ("$Id: gspack.c,v 1.4 2005/03/31 05:14:49 kloczek Exp $")
|
||||
#include <stdio.h>
|
||||
#include "defines.h"
|
||||
/*
|
||||
* sgr_pack - convert a shadow group structure to a packed
|
||||
* shadow group record
|
||||
*
|
||||
* sgr_pack takes the shadow group structure and packs
|
||||
* the components in a record. this record will be
|
||||
* unpacked later by sgr_unpack.
|
||||
*/
|
||||
int sgr_pack (const struct sgrp *sgrp, char *buf)
|
||||
{
|
||||
char *cp;
|
||||
int i;
|
||||
|
||||
/*
|
||||
* The name and password are both easy - append each string
|
||||
* to the buffer. These are always the first two strings
|
||||
* in a record.
|
||||
*/
|
||||
|
||||
cp = buf;
|
||||
strcpy (cp, sgrp->sg_name);
|
||||
cp += strlen (cp) + 1;
|
||||
|
||||
strcpy (cp, sgrp->sg_passwd);
|
||||
cp += strlen (cp) + 1;
|
||||
|
||||
/*
|
||||
* The arrays of administrators and members are slightly
|
||||
* harder. Each element is appended as a string, with a
|
||||
* final '\0' appended to serve as a blank string. The
|
||||
* number of elements is not known in advance, so the
|
||||
* entire collection of administrators must be scanned to
|
||||
* find the start of the members.
|
||||
*/
|
||||
|
||||
for (i = 0; sgrp->sg_adm[i]; i++) {
|
||||
strcpy (cp, sgrp->sg_adm[i]);
|
||||
cp += strlen (cp) + 1;
|
||||
}
|
||||
*cp++ = '\0';
|
||||
|
||||
for (i = 0; sgrp->sg_mem[i]; i++) {
|
||||
strcpy (cp, sgrp->sg_mem[i]);
|
||||
cp += strlen (cp) + 1;
|
||||
}
|
||||
*cp++ = '\0';
|
||||
|
||||
return cp - buf;
|
||||
}
|
||||
|
||||
/*
|
||||
* sgr_unpack - convert a packed shadow group record to an
|
||||
* unpacked record
|
||||
*
|
||||
* sgr_unpack converts a record which was packed by sgr_pack
|
||||
* into the normal shadow group structure format.
|
||||
*/
|
||||
|
||||
int sgr_unpack (char *buf, int len, struct sgrp *sgrp)
|
||||
{
|
||||
char *org = buf;
|
||||
int i;
|
||||
|
||||
/*
|
||||
* The name and password are both easy - they are the first
|
||||
* two strings in the record.
|
||||
*/
|
||||
|
||||
sgrp->sg_name = buf;
|
||||
buf += strlen (buf) + 1;
|
||||
if (buf - org > len)
|
||||
return -1;
|
||||
|
||||
sgrp->sg_passwd = buf;
|
||||
buf += strlen (buf) + 1;
|
||||
if (buf - org > len)
|
||||
return -1;
|
||||
|
||||
/*
|
||||
* The administrators and members are slightly more difficult.
|
||||
* The arrays are lists of strings. Each list is terminated
|
||||
* by a string of length zero. This string is detected by
|
||||
* looking for an initial character of '\0'.
|
||||
*/
|
||||
|
||||
for (i = 0; *buf && i < 1024; i++) {
|
||||
sgrp->sg_adm[i] = buf;
|
||||
buf += strlen (buf) + 1;
|
||||
|
||||
if (buf - org > len)
|
||||
return -1;
|
||||
}
|
||||
sgrp->sg_adm[i] = (char *) 0;
|
||||
if (!*buf)
|
||||
buf++;
|
||||
|
||||
for (i = 0; *buf && i < 1024; i++) {
|
||||
sgrp->sg_mem[i] = buf;
|
||||
buf += strlen (buf) + 1;
|
||||
|
||||
if (buf - org > len)
|
||||
return -1;
|
||||
}
|
||||
sgrp->sg_mem[i] = (char *) 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif /*} */
|
@@ -6,7 +6,7 @@
|
||||
* Juha Virtanen, <jiivee@hut.fi>; November 1995
|
||||
*/
|
||||
/*
|
||||
* $Id: prototypes.h,v 1.19 2005/05/25 18:20:22 kloczek Exp $
|
||||
* $Id: prototypes.h,v 1.22 2005/08/02 10:50:51 kloczek Exp $
|
||||
*
|
||||
* Added a macro to work around ancient (non-ANSI) compilers, just in case
|
||||
* someone ever tries to compile this with SunOS cc... --marekm
|
||||
@@ -84,21 +84,6 @@ extern int gr_dbm_present (void);
|
||||
/* grent.c */
|
||||
extern int putgrent (const struct group *, FILE *);
|
||||
|
||||
/* grpack.c */
|
||||
extern int gr_pack (const struct group *, char *);
|
||||
extern int gr_unpack (char *, int, struct group *);
|
||||
|
||||
#ifdef SHADOWGRP
|
||||
/* gsdbm.c */
|
||||
extern int sg_dbm_remove (const char *);
|
||||
extern int sg_dbm_update (const struct sgrp *);
|
||||
extern int sg_dbm_present (void);
|
||||
|
||||
/* gspack.c */
|
||||
extern int sgr_pack (const struct sgrp *, char *);
|
||||
extern int sgr_unpack (char *, int, struct sgrp *);
|
||||
#endif
|
||||
|
||||
/* hushed.c */
|
||||
extern int hushed (const struct passwd *);
|
||||
|
||||
@@ -142,15 +127,6 @@ extern void passwd_check (const char *, const char *, const char *);
|
||||
/* pwd_init.c */
|
||||
extern void pwd_init (void);
|
||||
|
||||
/* pwdbm.c */
|
||||
extern int pw_dbm_remove (const struct passwd *);
|
||||
extern int pw_dbm_update (const struct passwd *);
|
||||
extern int pw_dbm_present (void);
|
||||
|
||||
/* pwpack.c */
|
||||
extern int pw_pack (const struct passwd *, char *);
|
||||
extern int pw_unpack (char *, int, struct passwd *);
|
||||
|
||||
/* rlogin.c */
|
||||
extern int do_rlogin (const char *, char *, int, char *, int);
|
||||
|
||||
@@ -171,10 +147,6 @@ extern void setup_env (struct passwd *);
|
||||
/* shell.c */
|
||||
extern void shell (const char *, const char *);
|
||||
|
||||
/* sppack.c */
|
||||
extern int spw_pack (const struct spwd *, char *);
|
||||
extern int spw_unpack (char *, int, struct spwd *);
|
||||
|
||||
/* strtoday.c */
|
||||
extern long strtoday (const char *);
|
||||
|
||||
|
117
lib/pwpack.c
117
lib/pwpack.c
@@ -1,117 +0,0 @@
|
||||
/*
|
||||
* Copyright 1990 - 1994, Julianne Frances Haugh
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of Julianne F. Haugh nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY JULIE HAUGH AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL JULIE HAUGH OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID ("$Id: pwpack.c,v 1.7 2005/03/31 05:14:49 kloczek Exp $")
|
||||
#include <sys/types.h>
|
||||
#include "defines.h"
|
||||
#include <stdio.h>
|
||||
#include <pwd.h>
|
||||
/*
|
||||
* pw_pack - convert a (struct pwd) to a packed record
|
||||
* WARNING: buf must be large enough, no check for overrun!
|
||||
*/
|
||||
int pw_pack (const struct passwd *passwd, char *buf)
|
||||
{
|
||||
char *cp;
|
||||
|
||||
cp = buf;
|
||||
strcpy (cp, passwd->pw_name);
|
||||
cp += strlen (cp) + 1;
|
||||
|
||||
strcpy (cp, passwd->pw_passwd);
|
||||
cp += strlen (cp) + 1;
|
||||
|
||||
memcpy (cp, (const char *) &passwd->pw_uid, sizeof passwd->pw_uid);
|
||||
cp += sizeof passwd->pw_uid;
|
||||
|
||||
memcpy (cp, (const char *) &passwd->pw_gid, sizeof passwd->pw_gid);
|
||||
cp += sizeof passwd->pw_gid;
|
||||
|
||||
strcpy (cp, passwd->pw_gecos);
|
||||
cp += strlen (cp) + 1;
|
||||
|
||||
strcpy (cp, passwd->pw_dir);
|
||||
cp += strlen (cp) + 1;
|
||||
|
||||
strcpy (cp, passwd->pw_shell);
|
||||
cp += strlen (cp) + 1;
|
||||
|
||||
return cp - buf;
|
||||
}
|
||||
|
||||
/*
|
||||
* pw_unpack - convert a packed (struct pwd) record to a (struct pwd)
|
||||
*/
|
||||
|
||||
int pw_unpack (char *buf, int len, struct passwd *passwd)
|
||||
{
|
||||
char *org = buf;
|
||||
|
||||
memzero (passwd, sizeof *passwd);
|
||||
|
||||
passwd->pw_name = buf;
|
||||
buf += strlen (buf) + 1;
|
||||
if (buf - org > len)
|
||||
return -1;
|
||||
|
||||
passwd->pw_passwd = buf;
|
||||
buf += strlen (buf) + 1;
|
||||
if (buf - org > len)
|
||||
return -1;
|
||||
|
||||
memcpy ((void *) &passwd->pw_uid, (void *) buf, sizeof passwd->pw_uid);
|
||||
buf += sizeof passwd->pw_uid;
|
||||
if (buf - org > len)
|
||||
return -1;
|
||||
|
||||
memcpy ((void *) &passwd->pw_gid, (void *) buf, sizeof passwd->pw_gid);
|
||||
buf += sizeof passwd->pw_gid;
|
||||
if (buf - org > len)
|
||||
return -1;
|
||||
|
||||
passwd->pw_gecos = buf;
|
||||
buf += strlen (buf) + 1;
|
||||
if (buf - org > len)
|
||||
return -1;
|
||||
|
||||
passwd->pw_dir = buf;
|
||||
buf += strlen (buf) + 1;
|
||||
if (buf - org > len)
|
||||
return -1;
|
||||
|
||||
passwd->pw_shell = buf;
|
||||
buf += strlen (buf) + 1;
|
||||
if (buf - org > len)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
107
lib/sppack.c
107
lib/sppack.c
@@ -1,107 +0,0 @@
|
||||
/*
|
||||
* Copyright 1990 - 1994, Julianne Frances Haugh
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of Julianne F. Haugh nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY JULIE HAUGH AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL JULIE HAUGH OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID ("$Id: sppack.c,v 1.5 2005/05/25 18:20:22 kloczek Exp $")
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include "defines.h"
|
||||
int spw_pack (const struct spwd *spwd, char *buf)
|
||||
{
|
||||
char *cp;
|
||||
|
||||
cp = buf;
|
||||
strcpy (cp, spwd->sp_namp);
|
||||
cp += strlen (cp) + 1;
|
||||
|
||||
strcpy (cp, spwd->sp_pwdp);
|
||||
cp += strlen (cp) + 1;
|
||||
|
||||
memcpy (cp, &spwd->sp_min, sizeof spwd->sp_min);
|
||||
cp += sizeof spwd->sp_min;
|
||||
|
||||
memcpy (cp, &spwd->sp_max, sizeof spwd->sp_max);
|
||||
cp += sizeof spwd->sp_max;
|
||||
|
||||
memcpy (cp, &spwd->sp_lstchg, sizeof spwd->sp_lstchg);
|
||||
cp += sizeof spwd->sp_lstchg;
|
||||
|
||||
memcpy (cp, &spwd->sp_warn, sizeof spwd->sp_warn);
|
||||
cp += sizeof spwd->sp_warn;
|
||||
|
||||
memcpy (cp, &spwd->sp_inact, sizeof spwd->sp_inact);
|
||||
cp += sizeof spwd->sp_inact;
|
||||
|
||||
memcpy (cp, &spwd->sp_expire, sizeof spwd->sp_expire);
|
||||
cp += sizeof spwd->sp_expire;
|
||||
|
||||
memcpy (cp, &spwd->sp_flag, sizeof spwd->sp_flag);
|
||||
cp += sizeof spwd->sp_flag;
|
||||
|
||||
return cp - buf;
|
||||
}
|
||||
|
||||
int spw_unpack (char *buf, int len, struct spwd *spwd)
|
||||
{
|
||||
char *org = buf;
|
||||
|
||||
spwd->sp_namp = buf;
|
||||
buf += strlen (buf) + 1;
|
||||
|
||||
spwd->sp_pwdp = buf;
|
||||
buf += strlen (buf) + 1;
|
||||
|
||||
memcpy (&spwd->sp_min, buf, sizeof spwd->sp_min);
|
||||
buf += sizeof spwd->sp_min;
|
||||
|
||||
memcpy (&spwd->sp_max, buf, sizeof spwd->sp_max);
|
||||
buf += sizeof spwd->sp_max;
|
||||
|
||||
memcpy (&spwd->sp_lstchg, buf, sizeof spwd->sp_lstchg);
|
||||
buf += sizeof spwd->sp_lstchg;
|
||||
|
||||
memcpy (&spwd->sp_warn, buf, sizeof spwd->sp_warn);
|
||||
buf += sizeof spwd->sp_warn;
|
||||
|
||||
memcpy (&spwd->sp_inact, buf, sizeof spwd->sp_inact);
|
||||
buf += sizeof spwd->sp_inact;
|
||||
|
||||
memcpy (&spwd->sp_expire, buf, sizeof spwd->sp_expire);
|
||||
buf += sizeof spwd->sp_expire;
|
||||
|
||||
memcpy (&spwd->sp_flag, buf, sizeof spwd->sp_flag);
|
||||
buf += sizeof spwd->sp_flag;
|
||||
|
||||
if (buf - org > len)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user