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