#include <afs/param.h>
#include <roken.h>
+#include <afs/opr.h>
-#include <stdio.h>
#ifdef AFS_NT40_ENV
#include <WINNT/afsevent.h>
#endif
#include <ctype.h>
-#include <string.h>
+
#include <rx/rx.h>
#include <rx/xdr.h>
#include <afs/cellconfig.h>
#include <afs/afsutil.h>
#include <afs/com_err.h>
+
#include "ptclient.h"
#include "ptuser.h"
#include "pterror.h"
afs_int32 i;
afs_int32 fail = 0;
+ buf[0] = '\0';
+
if (argc < 2) {
fprintf(stderr, "Usage: readgroup [-v] [-c cellname] groupfile.\n");
exit(0);
verbose = 1;
else {
if (!strcmp(argv[i], "-c")) {
- cellname = (char *)malloc(100);
+ cellname = malloc(100);
strncpy(cellname, argv[++i], 100);
} else
strncpy(buf, argv[i], 150);
}
}
+
+ /* Catch missing filename */
+ if (buf[0] == '\0') {
+ fprintf(stderr, "Usage: readgroup [-v] [-c cellname] groupfile.\n");
+ exit(0);
+ }
+
code = pr_Initialize(2, AFSDIR_CLIENT_ETC_DIRPATH, cellname);
free(cellname);
if (code) {
} else {
/* add the members of a group to the group */
if (verbose)
- printf("Adding %s to %s.\n",
- lnames.namelist_val[i], gname);
+ printf("Adding %s to %s.\n", name, gname);
code = pr_ListMembers(name, &lnames);
if (code) {
fprintf(stderr,
name, gname);
fprintf(stderr, "%s (%d).\n", pr_ErrorMsg(code),
code);
+ } else {
+ for (i = 0; i < lnames.namelist_len; i++) {
+ code =
+ pr_AddToGroup(lnames.namelist_val[i], gname);
+ report_error(code, lnames.namelist_val[i], gname);
+ }
+ if (lnames.namelist_val)
+ free(lnames.namelist_val);
}
- for (i = 0; i < lnames.namelist_len; i++) {
- code =
- pr_AddToGroup(lnames.namelist_val[i], gname);
- report_error(code, lnames.namelist_val[i], gname);
- }
- if (lnames.namelist_val)
- free(lnames.namelist_val);
}
memset(name, 0, PR_MAXNAMELEN);
skip(&tmp);
name, gname);
fprintf(stderr, "%s (%d).\n", pr_ErrorMsg(code),
code);
+ } else {
+ for (i = 0; i < lnames.namelist_len; i++) {
+ if (verbose)
+ printf("Adding %s to %s.\n",
+ lnames.namelist_val[i], gname);
+ code = pr_AddToGroup(lnames.namelist_val[i], gname);
+ report_error(code, lnames.namelist_val[i], gname);
+ }
+ if (lnames.namelist_val)
+ free(lnames.namelist_val);
}
- for (i = 0; i < lnames.namelist_len; i++) {
- if (verbose)
- printf("Adding %s to %s.\n",
- lnames.namelist_val[i], gname);
- code = pr_AddToGroup(lnames.namelist_val[i], gname);
- report_error(code, lnames.namelist_val[i], gname);
- }
- if (lnames.namelist_val)
- free(lnames.namelist_val);
}
memset(name, 0, PR_MAXNAMELEN);
skip(&tmp);