Unix Technical Forum

expiration of accounts

This is a discussion on expiration of accounts within the Sco Unix forums, part of the Unix Operating Systems category; --> Hi, I have to set up useraccounts with rexec. So I'm only able te execute a command. I can't ...


Go Back   Unix Technical Forum > Unix Operating Systems > Sco Unix

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-15-2008, 11:18 AM
Daniel Voelkel
 
Posts: n/a
Default expiration of accounts

Hi,

I have to set up useraccounts with rexec. So I'm only able te execute a
command. I can't use dialogs (as needed for passwd). What I do so far is
the following:
useradd -u <UID> -d /<HOMEDIR>/<LOGNAME> -c '<DESCRIPTION>' <LOGNAME>
which creates an new account with all options I need.

The next I use is chpass, which sources I found in a newsgroup.
chpass <LOGNAME> <PASSWORD>
which set's a password for the account.

Everything is ok with chpass for accounts that already exist. The new
password is set correctly. With new accounts the user gets an "account
expired" on first login. Is there a chance to set the expiration-date
for accounts?

Thanks in advance,
Daniel

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-15-2008, 11:20 AM
John DuBois
 
Posts: n/a
Default Re: expiration of accounts

In article <bpcm0e$kg8$03$1@news.t-online.com>,
Daniel Voelkel <daniel.voelkel.NG@gmx.net> wrote:
>Hi,
>
>I have to set up useraccounts with rexec. So I'm only able te execute a
>command. I can't use dialogs (as needed for passwd). What I do so far is
>the following:
>useradd -u <UID> -d /<HOMEDIR>/<LOGNAME> -c '<DESCRIPTION>' <LOGNAME>
>which creates an new account with all options I need.
>
>The next I use is chpass, which sources I found in a newsgroup.
>chpass <LOGNAME> <PASSWORD>
>which set's a password for the account.
>
>Everything is ok with chpass for accounts that already exist. The new
>password is set correctly. With new accounts the user gets an "account
>expired" on first login. Is there a chance to set the expiration-date
>for accounts?


Are you sure the message is 'account expired'?
What OS and release are you using?
You should also include a pointer to the 'chpass' that you used.

John
--
John DuBois spcecdt@armory.com KC6QKZ/AE http://www.armory.com/~spcecdt/
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-15-2008, 11:20 AM
Daniel Voelkel
 
Posts: n/a
Default Re: expiration of accounts

> Are you sure the message is 'account expired'?
> What OS and release are you using?
> You should also include a pointer to the 'chpass' that you used.


Sorry. Correctly the password has expired, not the account. :-/
That's what happens on first login of the new account.

----
login: dvtest
Password:
Last successful login for dvtest: NEVER
Last unsuccessful login for dvtest: NEVER
Your password has expired
Setting password for user: dvtest
Old password:
----


The sourcecode of "chpass" is as follows:
----
#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));
return (putprpwnam(argv[1], p) ? 0 : 1);
}
----


Daniel




Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-15-2008, 11:21 AM
John DuBois
 
Posts: n/a
Default Re: expiration of accounts

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/
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-15-2008, 11:21 AM
Daniel Voelkel
 
Posts: n/a
Default Re: expiration of accounts

John DuBois wrote:
> In the following code, the only change made is to add this line:
>
> p->ufld.fd_schange = time(NULL);


Thanks a lot. It works.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 12:00 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com