void setupargs () { size_t sz = servers.size (); if (!sz) fatal << "At least one target server must be specified\n\t" << "(use '-' for localhost)\n"; if (realmup) { if (sz != 1 || !issrpkey (servers[0])) fatal << "Exactly one SRP key must be used with -r\n"; if (keys.size () || opts & (KM_NOESK | KM_NOSRP)) fatal << "-r flag cannot be used with -akS flags\n"; nkeyname = srp_prepend (servers[0]); } else for (u_int i = 0; i < sz; i++) if (!(servers[i] == "-") && issrpkey (servers[i])) keys.push_back (srp_prepend (servers[i])); }
void sfsgroupmgr::do_query (str group, grpmgr_query_cb qcb, bool expanded) { str gname; str ghost; if (!parsegroup (group, &gname, &ghost)) { (*qcb) (NULL, NULL); return; } gstate *st = New gstate (NULL, NULL, gname, ghost, expanded, 0, wrap (this, &sfsgroupmgr::query_done, qcb)); if (issrpkey (ghost)) kmgr->login (ghost, wrap (this, &sfsgroupmgr::login_cb, st), NULL, KM_NOSRP | KM_NOESK); else kmgr->connect (ghost, wrap (this, &sfsgroupmgr::connect_cb, st)); }
void sfskey_group (int argc, char **argv) { groupcmd *gc = New groupcmd (); int ch; while ((ch = getopt (argc, argv, "L:ECa:m:o:")) != -1) switch (ch) { case 'a': gc->keys.push_back (optarg); break; case 'm': if (optarg[0] != '+' && optarg[0] != '-') { warn ("Member names must begin with + (add) or - (remove)\n"); usage (); } if (strlen (optarg) > sfs_groupmember::maxsize) { warn ("Member name is too long (max 256 characters): %s\n", optarg); usage (); } gc->members.push_back (optarg); break; case 'o': if (optarg[0] != '+' && optarg[0] != '-') { warn ("Owner names must begin with + (add) or - (remove)\n"); usage (); } if (strlen (optarg) > sfs_groupmember::maxsize) { warn ("Owner name is too long (max 256 characters): %s\n", optarg); usage (); } gc->owners.push_back (optarg); break; case 'C': gc->create = true; break; case 'E': gc->expanded = true; break; case 'L': if (!convertint (optarg, &gc->version) || gc->version < 0) usage (); break; default: usage (); break; } if ((optind + 1 != argc) || (!sfsgroupmgr::parsegroup (argv[optind], &gc->gname, &gc->ghost))) usage (); gc->group = argv[optind]; if (!(gc->ghost == "-") && issrpkey (gc->ghost)) gc->keys.push_back (srp_prepend (gc->ghost)); if (gc->members.size () == 0 && gc->owners.size () == 0) if (gc->create) gc->update (); else if (gc->version >= 0) { if (gc->expanded) warn << "Expanded (-E) option doesn't apply to changelog queries. Ignoring...\n"; gc->changelog (); } else gc->query (); else { if (gc->expanded) warn << "Expanded (-E) option doesn't apply to updates. Ignoring...\n"; if (gc->version >= 0) warn << "Changelog (-L) option doesn't apply to updates. Ignoring...\n"; if (gc->owners.size () > 250) fatal << "Owners list is too big (> 250 entries) for a single update\n" << "and I don't want to split it up arbitrarily. Please issue\n" << "multiple `sfskey group' commands with the owners list split\n" << "up to provide the correct permissions semantics.\n"; if (gc->create) fatal << "Cannot use Create (-C) option with an owners/members list.\n"; gc->update (); } }