Valid ranges for uids for HP-UX

Hi ,

I am using adduser in hp-ux to create users in Hp-ux.
i would like to know what are the valid values for uids and gids in hp-ux

what are the rannges for the valid uids .

How to check what are the used uids in Hp-ux .

Thanks
Narendra babu C

"man limits" and look at UID_MAX

Thanks Perderabo for your answers.

I heard that we cannot use 0 -10 uid for creating users becos it is already reserved for HP_Ux system.

yes i can get userid max from man limts .

also one more question on this

how to check whether gived uid is not used or present /etc/passwd file or
is there any command to check for the same.

my c program looks like this , my intention is to create a user from a c program , so i tried this program , is it ok . Now it will give u a better idea what my question is ?

here my program accepts uid, groupname, username it works fine and i am exuting same with root permission . so i need to check whther a uid exists , group exist , name exists .

or i have to manually check from /etc/passwd, /etc/groupfile ?

int main (int argc, char *argv[])
{
int count;
char newuser[100],new_name[20],pass_user[50];
short new_uid;
char new_group[20];

    if \(argc > 1\)
    \{
            new_uid=atoi\(argv[1]\);
            strcpy\(new_group,argv[2]\);
            strcpy\(new_name , argv[3]\);

sprintf(newuser,"useradd -u %d -g %s -m %s|passwd -f %s\0",new_uid,new_g
roup,new_name,new_name);
system(newuser);

    \}
    else
    \{
            printf\("The command has less number of arguments.\\n"\);
    \}

    return 0;

}

Your advice is greatly appriciable

thanks
Narendra

First, you can omit the -u with useradd. Then useradd will just pick a uid. To read the passwd file in a C program, the best idea is to use getpwent(3). Then your program will still work if you switch from /etc/passwd to NIS or whatever

Thanks Perderabo ,

i omitted -u option , and it is adding the user with system genrated uid .
but it is throwing error "Invalid login name."

any reason why it is doing so .

even i want default passwd to set in single command so that when user first login he should change passwd or enter new passwd ?

my code stmt
sprintf(newuser,"useradd -g %s -m %s|passwd -d -f
%s\0",new_group,new_name,new_name);

but it is not working !

Please advice

many Thanks
narendra

Beats me. I have no way of knowing what user name you gave useradd.

I gave john has username

#./a.out users john ( command line )

users - group name
john - username

Thanks
narendra

Post the new code please. And check that you have made the necessary changes in here:

new_uid=atoi(argv[1]);
strcpy(new_group,argv[2]);
strcpy(new_name , argv[3]);

You need to change the above bit if you haven't already.