Re: gated 3.6A1 for 1.3.99 (diffs)

Cristian Gafton (gafton@sorosis.ro)
Sun, 9 Jun 1996 15:10:37 +0300 (EET DST)


On Mon, 13 May 1996, Marek Michalkiewicz wrote:

> pw = getpwnam(GII_USER);
> #ifdef SHADOW_PASSWD
> if (pw) {
> spw = getspnam(pw->pw_name);
> if (spw)
> pw->pw_passwd = spw->sp_pwdp;
> endspent();
> }
> #endif
> if (!pw || !pw->pw_passwd[0]) {
>
> (I suppose this should check for passwordless accounts - the original
> check does nothing because pw->pw_passwd is never a NULL pointer.)
>
> This way the same binary will work with both shadow and non-shadow
> passwords. For ELF systems, it is safe to always define SHADOW_PASSWD
> - getspnam() is in the standard libc-5.x.

Still, I seriously doubt that this will work on shadow-aware systems
without actually having /etc/shadow.

Why not check the presence of /etc/shadow and if it is present and size >
0 then proceed with shadow things ?

Something like:
struct stat stat_info;
/* check if /etc/shadow exists */
int is_shadowed = !stat("/etc/shadow", &stat_info) && stat_info.st_size;
...
pw = getpwnam(GII_USER);
#ifdef SHADOW_PASSWD
if (pw && is_shadowed) {
spw = getspnam(pw->pw_name);
if (spw)
pw->pw_passwd = spw->sp_pwdp;
endspent();
}
#endif

Am I missing something ?

Cristian Gafton

-------------------------------------------------------------------
Cristian Gafton, SysAdm gafton@sorosis.ro
Computers & Communications Center
35 Moara de Foc St., Iasi 6600, ROMANIA
http://www.cccis.ro
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Winning isn't everything ... but wanting to win is.