* src/groupmod.c: Re-indent.
* src/groupmod.c: Do not add the command synopsis to the main () documentation. This avoids outdated information.
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
2008-12-22 Nicolas François <nicolas.francois@centraliens.net>
|
2008-12-22 Nicolas François <nicolas.francois@centraliens.net>
|
||||||
|
|
||||||
* src/groupadd.c: Re-indent.
|
* src/groupadd.c, src/groupmod.c: Re-indent.
|
||||||
|
* src/groupmod.c: Do not add the command synopsis to the main ()
|
||||||
|
documentation. This avoids outdated information.
|
||||||
|
|
||||||
2008-12-22 Nicolas François <nicolas.francois@centraliens.net>
|
2008-12-22 Nicolas François <nicolas.francois@centraliens.net>
|
||||||
|
|
||||||
|
109
src/groupmod.c
109
src/groupmod.c
@@ -186,8 +186,8 @@ static void grp_update (void)
|
|||||||
ogrp = gr_locate (group_name);
|
ogrp = gr_locate (group_name);
|
||||||
if (!ogrp) {
|
if (!ogrp) {
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("%s: group '%s' does not exist in %s\n"),
|
_("%s: group '%s' does not exist in %s\n"),
|
||||||
Prog, group_name, gr_dbname ());
|
Prog, group_name, gr_dbname ());
|
||||||
exit (E_GRP_UPDATE);
|
exit (E_GRP_UPDATE);
|
||||||
}
|
}
|
||||||
grp = *ogrp;
|
grp = *ogrp;
|
||||||
@@ -277,7 +277,8 @@ static void check_new_gid (void)
|
|||||||
/*
|
/*
|
||||||
* Tell the user what they did wrong.
|
* Tell the user what they did wrong.
|
||||||
*/
|
*/
|
||||||
fprintf (stderr, _("%s: GID '%lu' already exists\n"),
|
fprintf (stderr,
|
||||||
|
_("%s: GID '%lu' already exists\n"),
|
||||||
Prog, (unsigned long int) group_newid);
|
Prog, (unsigned long int) group_newid);
|
||||||
exit (E_GID_IN_USE);
|
exit (E_GID_IN_USE);
|
||||||
}
|
}
|
||||||
@@ -306,8 +307,8 @@ static void check_new_name (void)
|
|||||||
/* local, no need for xgetgrnam */
|
/* local, no need for xgetgrnam */
|
||||||
if (getgrnam (group_newname) != NULL) {
|
if (getgrnam (group_newname) != NULL) {
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("%s: group '%s' already exists\n"), Prog,
|
_("%s: group '%s' already exists\n"),
|
||||||
group_newname);
|
Prog, group_newname);
|
||||||
exit (E_NAME_IN_USE);
|
exit (E_NAME_IN_USE);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@@ -317,8 +318,9 @@ static void check_new_name (void)
|
|||||||
* All invalid group names land here.
|
* All invalid group names land here.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
fprintf (stderr, _("%s: invalid group name '%s'\n"),
|
fprintf (stderr,
|
||||||
Prog, group_newname);
|
_("%s: invalid group name '%s'\n"),
|
||||||
|
Prog, group_newname);
|
||||||
exit (E_BAD_ARG);
|
exit (E_BAD_ARG);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -332,8 +334,9 @@ static gid_t get_gid (const char *gidstr)
|
|||||||
|
|
||||||
val = strtol (gidstr, &errptr, 10); /* FIXME: Should be strtoul ? */
|
val = strtol (gidstr, &errptr, 10); /* FIXME: Should be strtoul ? */
|
||||||
if (('\0' != *errptr) || (ERANGE == errno) || (val < 0)) {
|
if (('\0' != *errptr) || (ERANGE == errno) || (val < 0)) {
|
||||||
fprintf (stderr, _("%s: invalid numeric argument '%s'\n"), Prog,
|
fprintf (stderr,
|
||||||
gidstr);
|
_("%s: invalid numeric argument '%s'\n"),
|
||||||
|
Prog, gidstr);
|
||||||
exit (E_BAD_ARG);
|
exit (E_BAD_ARG);
|
||||||
}
|
}
|
||||||
return (gid_t) val;
|
return (gid_t) val;
|
||||||
@@ -348,40 +351,37 @@ static gid_t get_gid (const char *gidstr)
|
|||||||
*/
|
*/
|
||||||
static void process_flags (int argc, char **argv)
|
static void process_flags (int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
int option_index = 0;
|
||||||
{
|
int c;
|
||||||
int option_index = 0;
|
static struct option long_options[] = {
|
||||||
int c;
|
{"gid", required_argument, NULL, 'g'},
|
||||||
static struct option long_options[] = {
|
{"help", no_argument, NULL, 'h'},
|
||||||
{"gid", required_argument, NULL, 'g'},
|
{"new-name", required_argument, NULL, 'n'},
|
||||||
{"help", no_argument, NULL, 'h'},
|
{"non-unique", no_argument, NULL, 'o'},
|
||||||
{"new-name", required_argument, NULL, 'n'},
|
{"password", required_argument, NULL, 'p'},
|
||||||
{"non-unique", no_argument, NULL, 'o'},
|
{NULL, 0, NULL, '\0'}
|
||||||
{"password", required_argument, NULL, 'p'},
|
};
|
||||||
{NULL, 0, NULL, '\0'}
|
while ((c =
|
||||||
};
|
getopt_long (argc, argv, "g:hn:op:",
|
||||||
while ((c =
|
long_options, &option_index)) != -1) {
|
||||||
getopt_long (argc, argv, "g:hn:op:",
|
switch (c) {
|
||||||
long_options, &option_index)) != -1) {
|
case 'g':
|
||||||
switch (c) {
|
gflg = true;
|
||||||
case 'g':
|
group_newid = get_gid (optarg);
|
||||||
gflg = true;
|
break;
|
||||||
group_newid = get_gid (optarg);
|
case 'n':
|
||||||
break;
|
nflg = true;
|
||||||
case 'n':
|
group_newname = optarg;
|
||||||
nflg = true;
|
break;
|
||||||
group_newname = optarg;
|
case 'o':
|
||||||
break;
|
oflg = true;
|
||||||
case 'o':
|
break;
|
||||||
oflg = true;
|
case 'p':
|
||||||
break;
|
group_passwd = optarg;
|
||||||
case 'p':
|
pflg = true;
|
||||||
group_passwd = optarg;
|
break;
|
||||||
pflg = true;
|
default:
|
||||||
break;
|
usage ();
|
||||||
default:
|
|
||||||
usage ();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -676,14 +676,6 @@ void update_primary_groups (gid_t ogid, gid_t ngid)
|
|||||||
/*
|
/*
|
||||||
* main - groupmod command
|
* main - groupmod command
|
||||||
*
|
*
|
||||||
* The syntax of the groupmod command is
|
|
||||||
*
|
|
||||||
* groupmod [ -g gid [ -o ]] [ -n name ] group
|
|
||||||
*
|
|
||||||
* The flags are
|
|
||||||
* -g - specify a new group ID value
|
|
||||||
* -o - permit the group ID value to be non-unique
|
|
||||||
* -n - specify a new group name
|
|
||||||
*/
|
*/
|
||||||
int main (int argc, char **argv)
|
int main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
@@ -755,8 +747,9 @@ int main (int argc, char **argv)
|
|||||||
*/
|
*/
|
||||||
grp = getgrnam (group_name); /* local, no need for xgetgrnam */
|
grp = getgrnam (group_name); /* local, no need for xgetgrnam */
|
||||||
if (NULL == grp) {
|
if (NULL == grp) {
|
||||||
fprintf (stderr, _("%s: group '%s' does not exist\n"),
|
fprintf (stderr,
|
||||||
Prog, group_name);
|
_("%s: group '%s' does not exist\n"),
|
||||||
|
Prog, group_name);
|
||||||
exit (E_NOTFOUND);
|
exit (E_NOTFOUND);
|
||||||
} else {
|
} else {
|
||||||
group_id = grp->gr_gid;
|
group_id = grp->gr_gid;
|
||||||
@@ -771,13 +764,15 @@ int main (int argc, char **argv)
|
|||||||
char *nis_domain;
|
char *nis_domain;
|
||||||
char *nis_master;
|
char *nis_master;
|
||||||
|
|
||||||
fprintf (stderr, _("%s: group %s is a NIS group\n"),
|
fprintf (stderr,
|
||||||
Prog, group_name);
|
_("%s: group %s is a NIS group\n"),
|
||||||
|
Prog, group_name);
|
||||||
|
|
||||||
if (!yp_get_default_domain (&nis_domain) &&
|
if (!yp_get_default_domain (&nis_domain) &&
|
||||||
!yp_master (nis_domain, "group.byname", &nis_master)) {
|
!yp_master (nis_domain, "group.byname", &nis_master)) {
|
||||||
fprintf (stderr, _("%s: %s is the NIS master\n"),
|
fprintf (stderr,
|
||||||
Prog, nis_master);
|
_("%s: %s is the NIS master\n"),
|
||||||
|
Prog, nis_master);
|
||||||
}
|
}
|
||||||
exit (E_NOTFOUND);
|
exit (E_NOTFOUND);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user