2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 #include <afsconfig.h>
11 #include <afs/param.h>
16 #include <WINNT/afsevent.h>
21 #include <afs/cellconfig.h>
22 #include <afs/afsutil.h>
23 #include <afs/com_err.h>
27 #include "ptprototypes.h"
32 /* OK, this REALLY sucks bigtime, but I can't tell who is calling
33 * afsconf_CheckAuth easily, and only *SERVERS* should be calling osi_audit
34 * anyway. It's gonna give somebody fits to debug, I know, I know.
39 #include "AFS_component_version_number.c"
42 main(afs_int32 argc, char **argv)
46 char name[PR_MAXNAMELEN];
55 afs_int32 verbose = 0;
59 fprintf(stderr, "Usage: readpwd [-v] [-c cellname] passwdfile.\n");
63 for (i = 1; i < argc; i++) {
64 if (!strcmp(argv[i], "-v"))
67 if (!strcmp(argv[i], "-c")) {
68 cellname = (char *)malloc(100);
69 strncpy(cellname, argv[++i], 100);
71 strncpy(buf, argv[i], 150);
74 code = pr_Initialize(2, AFSDIR_CLIENT_ETC_DIRPATH, cellname);
77 fprintf(stderr, "pr_Initialize failed, code %d.\n", code);
82 if ((fp = fopen(buf, "r")) == NULL) {
83 fprintf(stderr, "Couldn't open %s.\n", argv[1]);
86 while ((tmp = fgets(buf, 150, fp)) != NULL) {
87 memset(name, 0, PR_MAXNAMELEN);
89 ptr = strchr(buf, ':');
90 strncpy(name, buf, ptr - buf);
91 aptr = strchr(++ptr, ':');
92 ptr = strchr(++aptr, ':');
93 strncpy(uid, aptr, ptr - aptr);
96 printf("Adding %s with id %d.\n", name, id);
97 code = pr_CreateUser(name, &id);
99 fprintf(stderr, "Failed to add user %s with id %d!\n", name, id);
100 fprintf(stderr, "%s (%d).\n", pr_ErrorMsg(code), code);