Sync 2.2.2 and HEAD (I will keep these the same if it kills me :-).
[kai/samba.git] / source3 / utils / pdbedit.c
1 /* 
2    Unix SMB/Netbios implementation.
3    passdb editing frontend
4    Version 3.0
5    
6    Copyright (C) Simo Sorce      2000
7    Copyright (C) Andrew Bartlett 2001   
8
9    This program is free software; you can redistribute it and/or modify
10    it under the terms of the GNU General Public License as published by
11    the Free Software Foundation; either version 2 of the License, or
12    (at your option) any later version.
13    
14    This program is distributed in the hope that it will be useful,
15    but WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17    GNU General Public License for more details.
18    
19    You should have received a copy of the GNU General Public License
20    along with this program; if not, write to the Free Software
21    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */
23
24 /* base uid for trust accounts is set to 60000 ! 
25  * May be we should add the defines in smb.h to make it possible having 
26  * different values on different platforms?
27  */
28
29 #define BASE_MACHINE_UID 60000
30 #define MAX_MACHINE_UID 65500 /* 5500 trust accounts aren't enough? */
31
32 #include "includes.h"
33
34 extern pstring global_myname;
35 extern int DEBUGLEVEL;
36
37 /*
38  * Next two lines needed for SunOS and don't
39  * hurt anything else...
40  */
41 extern char *optarg;
42 extern int optind;
43
44 /*********************************************************
45  Print command usage on stderr and die.
46 **********************************************************/
47 static void usage(void)
48 {
49         if (getuid() == 0) {
50                 printf("tdbedit options\n");
51         } else {
52                 printf("You need to be root to use this tool!\n");
53         }
54         printf("(actually to add a user you need to use smbpasswd)\n");
55         printf("options:\n");
56         printf("  -l                   list usernames\n");
57         printf("     -v                verbose output\n");
58         printf("     -w                smbpasswd file style\n");
59         printf("  -u username          print user's info\n");
60         printf("     -f fullname       set Full Name\n");
61         printf("     -h homedir        set home directory\n");
62         printf("     -d drive          set home dir drive\n");
63         printf("     -s script         set logon script\n");
64         printf("     -p profile        set profile path\n");
65         printf("  -a                   create new account\n");
66         printf("     -m                it is a machine trust\n");
67         printf("  -x                   delete this user\n");
68         printf("  -i file              import account from file (smbpasswd style)\n");
69         exit(1);
70 }
71
72 /*********************************************************
73  Print info from sam structure
74 **********************************************************/
75
76 static int print_sam_info (SAM_ACCOUNT *sam_pwent, BOOL verbosity, BOOL smbpwdstyle)
77 {
78         /* TODO: chaeck if entry is a user or a workstation */
79         if (!sam_pwent) return -1;
80         
81         if (verbosity) {
82                 printf ("username:       %s\n", sam_pwent->username);
83                 printf ("user ID/Group:  %d/%d\n", sam_pwent->uid,
84                                                   sam_pwent->gid);
85                 printf ("user RID/GRID:  %d/%d\n", sam_pwent->user_rid,
86                                                   sam_pwent->group_rid);
87                 printf ("Full Name:      %s\n", sam_pwent->full_name);
88                 printf ("Home Directory: %s\n", sam_pwent->home_dir);
89                 printf ("HomeDir Drive:  %s\n", sam_pwent->dir_drive);
90                 printf ("Logon Script:   %s\n", sam_pwent->logon_script);
91                 printf ("Profile Path:   %s\n", sam_pwent->profile_path);
92         } else if (smbpwdstyle) {
93                 char lm_passwd[33];
94                 char nt_passwd[33];
95                 pdb_sethexpwd(lm_passwd, 
96                               pdb_get_lanman_passwd(sam_pwent), 
97                               pdb_get_acct_ctrl(sam_pwent));
98                 pdb_sethexpwd(nt_passwd, 
99                               pdb_get_nt_passwd(sam_pwent), 
100                               pdb_get_acct_ctrl(sam_pwent));
101                 
102                 printf("%s:%d:%s:%s:%s:LCT-%08X:\n",
103                        pdb_get_username(sam_pwent),
104                        pdb_get_uid(sam_pwent),
105                        lm_passwd,
106                        nt_passwd,
107                        pdb_encode_acct_ctrl(pdb_get_acct_ctrl(sam_pwent),NEW_PW_FORMAT_SPACE_PADDED_LEN),
108                        (uint32)pdb_get_pass_last_set_time(sam_pwent));
109         } else {
110                 printf ("%s:%d:%s\n", sam_pwent->username, sam_pwent->uid, sam_pwent->full_name);
111         }       
112         
113         return 0;       
114 }
115
116 /*********************************************************
117  Get an Print User Info
118 **********************************************************/
119
120 static int print_user_info (char *username, BOOL verbosity, BOOL smbpwdstyle)
121 {
122         SAM_ACCOUNT *sam_pwent=NULL;
123         BOOL ret;
124         
125         pdb_init_sam(&sam_pwent);
126         
127         ret = pdb_getsampwnam (sam_pwent, username);
128
129         if (ret==False) {
130                 fprintf (stderr, "Username not found!\n");
131                 pdb_free_sam(sam_pwent);
132                 return -1;
133         }
134         
135         ret=print_sam_info (sam_pwent, verbosity, smbpwdstyle);
136         pdb_free_sam(sam_pwent);
137         
138         return ret;
139 }
140         
141 /*********************************************************
142  List Users
143 **********************************************************/
144 static int print_users_list (BOOL verbosity, BOOL smbpwdstyle)
145 {
146         SAM_ACCOUNT *sam_pwent=NULL;
147         BOOL ret;
148         
149         pdb_init_sam(&sam_pwent);
150
151         ret = pdb_setsampwent(False);
152         if (ret && errno == ENOENT) {
153                 fprintf (stderr,"Password database not found!\n");
154                 pdb_free_sam(sam_pwent);
155                 exit(1);
156         }
157
158         while ((ret = pdb_getsampwent (sam_pwent))) {
159                 if (verbosity)
160                         printf ("---------------\n");
161                 print_sam_info (sam_pwent, verbosity, smbpwdstyle);
162                 pdb_reset_sam(sam_pwent);
163         }
164         
165         pdb_endsampwent ();
166         pdb_free_sam(sam_pwent);
167         return 0;
168 }
169
170 /*********************************************************
171  Set User Info
172 **********************************************************/
173
174 static int set_user_info (char *username, char *fullname, char *homedir, char *drive, char *script, char *profile)
175 {
176         SAM_ACCOUNT *sam_pwent=NULL;
177         BOOL ret;
178         
179         pdb_init_sam(&sam_pwent);
180         
181         ret = pdb_getsampwnam (sam_pwent, username);
182         if (ret==False) {
183                 fprintf (stderr, "Username not found!\n");
184                 pdb_free_sam(sam_pwent);
185                 return -1;
186         }
187         
188         if (fullname)
189                 pdb_set_fullname(sam_pwent, fullname);
190         if (homedir)
191                 pdb_set_homedir(sam_pwent, homedir);
192         if (drive)
193                 pdb_set_dir_drive(sam_pwent,drive);
194         if (script)
195                 pdb_set_logon_script(sam_pwent, script);
196         if (profile)
197                 pdb_set_profile_path (sam_pwent, profile);
198         
199         if (pdb_update_sam_account (sam_pwent, True))
200                 print_user_info (username, True, False);
201         else {
202                 fprintf (stderr, "Unable to modify entry!\n");
203                 pdb_free_sam(sam_pwent);
204                 return -1;
205         }
206         pdb_free_sam(sam_pwent);
207         return 0;
208 }
209
210 /*********************************************************
211  Add New User
212 **********************************************************/
213 static int new_user (char *username, char *fullname, char *homedir, char *drive, char *script, char *profile)
214 {
215         SAM_ACCOUNT *sam_pwent=NULL;
216         struct passwd  *pwd = NULL;
217         char *password1, *password2;
218         
219         ZERO_STRUCT(sam_pwent);
220
221         pdb_init_sam (&sam_pwent);
222
223         if (!(pwd = sys_getpwnam(username))) {
224                 fprintf (stderr, "User %s does not exist in system passwd!\n", username);
225                 pdb_free_sam (sam_pwent);
226                 return -1;
227         }
228         
229         password1 = getpass("new password:");
230         password2 = getpass("retype new password:");
231         if (strcmp (password1, password2)) {
232                  fprintf (stderr, "Passwords does not match!\n");
233                  pdb_free_sam (sam_pwent);
234                  return -1;
235         }
236
237         pdb_set_plaintext_passwd(sam_pwent, password1);
238
239         pdb_set_username(sam_pwent, username);
240         if (fullname)
241                 pdb_set_fullname(sam_pwent, fullname);
242         if (homedir)
243                 pdb_set_homedir (sam_pwent, homedir);
244         if (drive)
245                 pdb_set_dir_drive (sam_pwent, drive);
246         if (script)
247                 pdb_set_logon_script(sam_pwent, script);
248         if (profile)
249                 pdb_set_profile_path (sam_pwent, profile);
250         
251         /* TODO: Check uid not being in MACHINE UID range!! */
252         pdb_set_uid (sam_pwent, pwd->pw_uid);
253         pdb_set_gid (sam_pwent, pwd->pw_gid);
254         pdb_set_user_rid (sam_pwent, pdb_uid_to_user_rid (pwd->pw_uid));
255         pdb_set_group_rid (sam_pwent, pdb_gid_to_group_rid (pwd->pw_gid));
256
257         pdb_set_acct_ctrl (sam_pwent, ACB_NORMAL);
258         
259         if (pdb_add_sam_account (sam_pwent)) { 
260                 print_user_info (username, True, False);
261         } else {
262                 fprintf (stderr, "Unable to add user! (does it alredy exist?)\n");
263                 pdb_free_sam (sam_pwent);
264                 return -1;
265         }
266         pdb_free_sam (sam_pwent);
267         return 0;
268 }
269
270 /*********************************************************
271  Add New Machine
272 **********************************************************/
273
274 static int new_machine (char *machinename)
275 {
276         SAM_ACCOUNT *sam_pwent=NULL;
277         SAM_ACCOUNT *sam_trust=NULL;
278         char name[16];
279         char *password = NULL;
280         uid_t uid;
281         
282         pdb_init_sam (&sam_pwent);
283
284         if (machinename[strlen (machinename) -1] == '$')
285                 machinename[strlen (machinename) -1] = '\0';
286         
287         safe_strcpy (name, machinename, 16);
288         safe_strcat (name, "$", 16);
289         
290         string_set (&password, machinename);
291         strlower_m(password);
292         
293         pdb_set_plaintext_passwd (sam_pwent, password);
294
295         pdb_set_username (sam_pwent, name);
296         
297         for (uid=BASE_MACHINE_UID; uid<=MAX_MACHINE_UID; uid++) {
298                 pdb_init_sam (&sam_trust);
299                 if (pdb_getsampwuid (sam_trust, uid)) {
300                         pdb_free_sam (sam_trust);
301                 } else {
302                         break;
303                 }
304         }
305
306         if (uid>MAX_MACHINE_UID) {
307                 fprintf (stderr, "No more free UIDs available to Machine accounts!\n");
308                 pdb_free_sam(sam_pwent);                
309                 return -1;
310         }
311
312         pdb_set_uid (sam_pwent, uid);
313         pdb_set_gid (sam_pwent, BASE_MACHINE_UID); /* TODO: set there more appropriate value!! */
314         pdb_set_user_rid (sam_pwent,pdb_uid_to_user_rid (uid));
315         pdb_set_group_rid (sam_pwent, pdb_gid_to_group_rid (BASE_MACHINE_UID));
316         pdb_set_acct_ctrl (sam_pwent, ACB_WSTRUST);
317         
318         if (pdb_add_sam_account (sam_pwent)) {
319                 print_user_info (name, True, False);
320         } else {
321                 fprintf (stderr, "Unable to add machine! (does it already exist?)\n");
322                 pdb_free_sam (sam_pwent);
323                 return -1;
324         }
325         pdb_free_sam (sam_pwent);
326         return 0;
327 }
328
329 /*********************************************************
330  Delete user entry
331 **********************************************************/
332
333 static int delete_user_entry (char *username)
334 {
335         return pdb_delete_sam_account (username);
336 }
337
338 /*********************************************************
339  Delete machine entry
340 **********************************************************/
341
342 static int delete_machine_entry (char *machinename)
343 {
344         char name[16];
345         
346         safe_strcpy (name, machinename, 16);
347         if (name[strlen(name)] != '$')
348                 safe_strcat (name, "$", 16);
349         return pdb_delete_sam_account (name);
350 }
351
352 /*********************************************************
353  Import smbpasswd style file
354 **********************************************************/
355
356 static int import_users (char *filename)
357 {
358         FILE *fp = NULL;
359         SAM_ACCOUNT *sam_pwent = NULL;
360         static pstring  user_name;
361         static unsigned char smbpwd[16];
362         static unsigned char smbntpwd[16];
363         char linebuf[256];
364         size_t linebuf_len;
365         unsigned char c;
366         unsigned char *p;
367         long uidval;
368         int line = 0;
369         int good = 0;
370
371         if (!pdb_init_sam (&sam_pwent)) {
372                 fprintf (stderr, "pdb_init_sam FAILED!\n");
373         }
374
375         if((fp = sys_fopen(filename, "rb")) == NULL) {
376                 fprintf (stderr, "%s\n", strerror (ferror (fp)));
377                 return -1;
378         }
379         
380         while (!feof(fp)) {
381                 /*Get a new line*/
382                 linebuf[0] = '\0';
383                 fgets(linebuf, 256, fp);
384                 if (ferror(fp)) {
385                         fprintf (stderr, "%s\n", strerror (ferror (fp)));
386                         pdb_free_sam(sam_pwent);
387                         return -1;
388                 }
389                 if ((linebuf_len = strlen(linebuf)) == 0) {
390                         line++;
391                         continue;
392                 }
393                 if (linebuf[linebuf_len - 1] != '\n') {
394                         c = '\0';
395                         while (!ferror(fp) && !feof(fp)) {
396                                 c = fgetc(fp);
397                                 if (c == '\n') break;
398                         }
399                 } else
400                         linebuf[linebuf_len - 1] = '\0';
401                 linebuf[linebuf_len] = '\0';
402                 if ((linebuf[0] == 0) && feof(fp)) {
403                         /*end of file!!*/
404                         pdb_free_sam(sam_pwent);
405                         return 0;
406                 }
407                 line++;
408                 if (linebuf[0] == '#' || linebuf[0] == '\0')
409                         continue;
410                 
411                 pdb_set_acct_ctrl (sam_pwent,ACB_NORMAL);
412                 
413                 /* Get user name */
414                 p = (unsigned char *) strchr_m(linebuf, ':');
415                 if (p == NULL) {
416                         fprintf (stderr, "Error: malformed password entry at line %d !!\n", line);
417                         pdb_reset_sam (sam_pwent);
418                         continue;
419                 }
420                 strncpy(user_name, linebuf, PTR_DIFF(p, linebuf));
421                 user_name[PTR_DIFF(p, linebuf)] = '\0';
422
423                 /* Get smb uid. */
424                 p++;
425                 if(*p == '-') {
426                         fprintf (stderr, "Error: negative uid at line %d\n", line);
427                         pdb_reset_sam (sam_pwent);
428                         continue;
429                 }
430                 if (!isdigit(*p)) {
431                         fprintf (stderr, "Error: malformed password entry at line %d (uid not number)\n", line);
432                         pdb_reset_sam (sam_pwent);
433                         continue;
434                 }
435                 uidval = atoi((char *) p);
436                 while (*p && isdigit(*p)) p++;
437                 if (*p != ':') {
438                         fprintf (stderr, "Error: malformed password entry at line %d (no : after uid)\n", line);
439                         pdb_reset_sam (sam_pwent);
440                         continue;
441                 }
442
443                 pdb_set_username(sam_pwent, user_name);
444                 pdb_set_uid (sam_pwent, uidval);
445                 
446                 /* Get passwords */
447                 p++;
448                 if (*p == '*' || *p == 'X') {
449                         /* Password deliberately invalid */
450                         fprintf (stderr, "Warning: entry invalidated for user %s\n", user_name);
451                         pdb_set_lanman_passwd(sam_pwent, NULL);
452                         pdb_set_nt_passwd(sam_pwent,NULL);
453                         pdb_set_acct_ctrl(sam_pwent, pdb_get_acct_ctrl(sam_pwent) | ACB_DISABLED);
454                 } else {
455                         if (linebuf_len < (PTR_DIFF(p, linebuf) + 33)) {
456                                 fprintf (stderr, "Error: malformed password entry at line %d (password too short)\n",line);
457                                 pdb_reset_sam (sam_pwent);
458                                 continue;
459                         }
460                         if (p[32] != ':') {
461                                 fprintf (stderr, "Error: malformed password entry at line %d (no terminating :)\n",line);
462                                 pdb_reset_sam (sam_pwent);
463                                 continue;
464                         }
465                         if (!strncasecmp((char *) p, "NO PASSWORD", 11)) {
466                                 pdb_set_lanman_passwd(sam_pwent, NULL);
467                                 pdb_set_acct_ctrl(sam_pwent, pdb_get_acct_ctrl(sam_pwent) | ACB_PWNOTREQ);
468                         } else {
469                                 if (!smbpasswd_gethexpwd((char *)p, smbpwd)) {
470                                         fprintf (stderr, "Error: malformed Lanman password entry at line %d (non hex chars)\n", line);
471                                         pdb_reset_sam (sam_pwent);
472                                         continue;
473                                 }
474                                 pdb_set_lanman_passwd(sam_pwent, smbpwd);
475                         }
476                         /* NT password */
477                         pdb_set_nt_passwd(sam_pwent, smbpwd);
478                         p += 33;
479                         if ((linebuf_len >= (PTR_DIFF(p, linebuf) + 33)) && (p[32] == ':')) {
480                                 if (*p != '*' && *p != 'X') {
481                                         if (pdb_gethexpwd((char *)p,smbntpwd)) {
482                                                 pdb_set_nt_passwd(sam_pwent, smbntpwd);
483                                         }
484                                 }
485                                 p += 33;
486                         }
487                 }
488
489                 /* Get ACCT_CTRL field if any */
490                 if (*p == '[') {
491                         uint16 acct_ctrl;
492                         unsigned char *end_p = (unsigned char *)strchr_m((char *)p, ']');
493                         
494                         acct_ctrl = pdb_decode_acct_ctrl((char*)p);
495                         if (acct_ctrl)
496                                 acct_ctrl = ACB_NORMAL;
497
498                         pdb_set_acct_ctrl(sam_pwent, acct_ctrl);
499                         
500                         /* Get last change time */
501                         if(end_p)
502                                 p = end_p + 1;
503                         if(*p == ':') {
504                                 p++;
505                                 if(*p && (StrnCaseCmp((char *)p, "LCT-", 4)==0)) {
506                                         int i;
507                                         
508                                         p += 4;
509                                         for(i = 0; i < 8; i++) {
510                                                 if(p[i] == '\0' || !isxdigit(p[i])) break;
511                                         }
512                                         if(i == 8) {
513                                                  pdb_set_pass_last_set_time (sam_pwent, (time_t)strtol((char *)p, NULL, 16));
514                                         }
515                                 }
516                         }
517                 }
518
519                 /* Old-style workstation account code droped. */
520
521                 if (pdb_get_acct_ctrl(sam_pwent) & ACB_WSTRUST) {
522                         if ((uidval < BASE_MACHINE_UID) || (uidval > MAX_MACHINE_UID)) {
523                                 fprintf (stderr, "Warning: Machine UID out of normal range %d-%d\n",
524                                                  BASE_MACHINE_UID,
525                                                  MAX_MACHINE_UID);
526                         }
527                         pdb_set_uid(sam_pwent, BASE_MACHINE_UID);
528                 }
529         
530                 /* Test if user is valid */
531                 if (pdb_get_acct_ctrl(sam_pwent) & ACB_NORMAL) {
532                         struct passwd  *pwd = NULL;
533
534                         if (!(pwd = sys_getpwnam(user_name))) {
535                                 fprintf (stderr, "Error: User %s does not exist in system passwd!\n", user_name);
536                                 continue;
537                         }
538                         pdb_set_gid(sam_pwent, pwd->pw_gid);
539                 }
540
541                 /* Fill in sam_pwent structure */
542                 pdb_set_user_rid(sam_pwent, pdb_uid_to_user_rid (pdb_get_uid(sam_pwent)));
543                 pdb_set_group_rid(sam_pwent, pdb_gid_to_group_rid (pdb_get_gid(sam_pwent)));
544
545                 /* TODO: set also full_name, home_dir, dir_drive, logon_script, profile_path, ecc...
546                  * when defaults will be available (after passdb redesign)
547                  * let them blank just now they are not used anyway
548                  */
549                                          
550                  /* Now ADD the entry */
551                 if (!(pdb_add_sam_account (sam_pwent))) {
552                         fprintf (stderr, "Unable to add user entry!\n");
553                         pdb_reset_sam (sam_pwent);
554                         continue;
555                 }
556                 printf ("%s imported!\n", user_name);
557                 good++;
558                 pdb_reset_sam (sam_pwent);
559         }
560         printf ("%d lines read.\n%d entryes imported\n", line, good);
561         pdb_free_sam(sam_pwent);        
562         return 0;
563 }
564
565 /*********************************************************
566  Start here.
567 **********************************************************/
568
569 int main (int argc, char **argv)
570 {
571         int ch;
572         static pstring servicesf = CONFIGFILE;
573         BOOL list_users = False;
574         BOOL verbose = False;
575         BOOL spstyle = False;
576         BOOL setparms = False;
577         BOOL machine = False;
578         BOOL add_user = False;
579         BOOL delete_user = False;
580         BOOL import = False;
581         char *user_name = NULL;
582         char *full_name = NULL;
583         char *home_dir = NULL;
584         char *home_drive = NULL;
585         char *logon_script = NULL;
586         char *profile_path = NULL;
587         char *smbpasswd = NULL;
588
589         TimeInit();
590         
591         setup_logging("tdbedit", True);
592
593         if (argc < 2) {
594                 usage();
595                 return 0;
596         }
597         
598         if(!initialize_password_db(True)) {
599                 fprintf(stderr, "Can't setup password database vectors.\n");
600                 exit(1);
601         }
602         
603         if (!lp_load(servicesf,True,False,False)) {
604                 fprintf(stderr, "Can't load %s - run testparm to debug it\n", 
605                         servicesf);
606                 exit(1);
607         }
608         
609         while ((ch = getopt(argc, argv, "ad:f:h:i:lmp:s:u:vwx")) != EOF) {
610                 switch(ch) {
611                 case 'a':
612                         add_user = True;
613                         break;
614                 case 'm':
615                         machine = True;
616                         break;
617                 case 'l':
618                         list_users = True;
619                         break;
620                 case 'v':
621                         verbose = True;
622                         break;
623                 case 'w':
624                         spstyle = True;
625                         break;
626                 case 'u':
627                         user_name = optarg;
628                         break;
629                 case 'f':
630                         setparms = True;
631                         full_name = optarg;
632                         break;
633                 case 'h':
634                         setparms = True;
635                         home_dir = optarg;
636                         break;
637                 case 'd':
638                         setparms = True;
639                         home_drive = optarg;
640                         break;
641                 case 's':
642                         setparms = True;
643                         logon_script = optarg;
644                         break;
645                 case 'p':
646                         setparms = True;
647                         profile_path = optarg;
648                         break;
649                 case 'x':
650                         delete_user = True;
651                         break;
652                 case 'i':
653                         import = True;
654                         smbpasswd = optarg;
655                         break;
656                 default:
657                         usage();
658                 }
659         }
660         if (((add_user?1:0) + (delete_user?1:0) + (list_users?1:0) + (import?1:0) + (setparms?1:0)) > 1) {
661                 fprintf (stderr, "Incompatible options on command line!\n");
662                 usage();
663                 exit(1);
664         }
665
666         if (add_user) {
667                 if (!user_name) {
668                         fprintf (stderr, "Username not specified! (use -u option)\n");
669                         return -1;
670                 }
671                 if (machine)
672                         return new_machine (user_name);
673                 else
674                         return new_user (user_name, full_name, home_dir, home_drive, logon_script, profile_path);
675         }
676
677         if (delete_user) {
678                 if (!user_name) {
679                         fprintf (stderr, "Username not specified! (use -u option)\n");
680                         return -1;
681                 }
682                 if (machine)
683                         return delete_machine_entry (user_name);
684                 else
685                         return delete_user_entry (user_name);
686         }
687         
688         if (user_name) {
689                 if (setparms)
690                         set_user_info ( user_name, full_name,
691                                                 home_dir,
692                                                 home_drive,
693                                                 logon_script,
694                                                 profile_path);
695                 else
696                         return print_user_info (user_name, verbose, spstyle);
697                 
698                 return 0;
699         }
700
701         
702         if (list_users) 
703                 return print_users_list (verbose, spstyle);
704         
705         if (import) 
706                 return import_users (smbpasswd); 
707         
708         usage();
709
710         return 0;
711 }