Subject: Re: expiration of accounts References: <bpcm0e$kg8$03$1@news.t-online.com>
<3fbc0bc4$0$1096$8eec23a@newsreader.tycho.net>
<bphtao$ej6$03$1@news.t-online.com> From: spcecdt@deeptht.armory.com (John DuBois) Date: 20 Nov 2003 23:38:57 GMT In article <bphtao$ej6$03$1@news.t-online.com>, Daniel Voelkel <daniel.voelkel.NG@gmx.net> wrote: >The sourcecode of "chpass" is as follows: After an account is created with useradd, it can't be logged into until the protected password database indicates that the password has been set. The program you're using sets the password, but fails to set the time the password was set, which indicates to the login process that the password still has never been set.
In the following code, the only change made is to add this line:
p->ufld.fd_schange = time(NULL);
I've include the entire program here for the sake of future readers.
John
#include <sys/types.h>
#include <sys/security.h>
#include <sys/audit.h>
#include <prot.h>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <time.h>
/** Global variables **/
static struct pr_passwd *p;
int main(argc, argv)
int argc;
char *argv[];
{
char salt[3], *passwd, *newpasswd;
set_auth_parameters(argc, argv);
if ((argc < 3) && (argc > 4))
{ return (1);
}
if ((p = getprpwnam(argv[1])) == NULL)
{ return (1);
}
if (argc == 4)
{ salt[0] = p->ufld.fd_encrypt[0];
salt[1] = p->ufld.fd_encrypt[1];
salt[2] = '\0';
if (strcmp(bigcrypt(argv[2], salt), p->ufld.fd_encrypt) != 0 )
return(2);
}
sprintf(salt,"%2.2d",(time((time_t *)NULL) % 100));
strcpy(p->ufld.fd_encrypt, bigcrypt(argv[argc - 1], salt));
p->ufld.fd_schange = time(NULL);
return (putprpwnam(argv[1], p) ? 0 : 1);
}
--
John DuBois spcecdt@armory.com KC6QKZ/AE http://www.armory.com/~spcecdt/
Have you tried Searching this site?
Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates
This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more. We appreciate comments and article submissions.
Many of the products and books I review are things I purchased for my own use. Some were given to me specifically for the purpose of reviewing them. I resell or can earn commissions from the sale of some of these items. Links within these pages may be affiliate links that pay me for referring you to them. That's mostly insignificant amounts of money; whenever it is not I have made my relationship plain. I also may own stock in companies mentioned here. If you have any question, please do feel free to contact me.
Specific links that take you to pages that allow you to purchase the item I reviewed are very likely to pay me a commission. Many of the books I review were given to me by the publishers specifically for the purpose of writing a review. These gifts and referral fees do not affect my opinions; I often give bad reviews anyway.
We use Google third-party advertising companies to serve ads when you visit our website. These companies may use information (not including your name, address, email address, or telephone number) about your visits to this and other websites in order to provide advertisements about goods and services of interest to you. If you would like more information about this practice and to know your choices about not having this information used by these companies, click here.
Click here to add your comments
Don't miss responses! Subscribe to Comments by RSS or by Email
Click here to add your comments
If you want a picture to show with your comment, go get a Gravatar