newgrp_SOURCES = login-utils/newgrp.c
newgrp_CFLAGS = $(SUID_CFLAGS) $(AM_CFLAGS)
newgrp_LDFLAGS = $(SUID_LDFLAGS) $(AM_LDFLAGS)
-newgrp_LDADD = $(LDADD)
+newgrp_LDADD = $(LDADD) libcommon.la
if HAVE_LIBCRYPT
newgrp_LDADD += -lcrypt
endif
== SYNOPSIS
-*newgrp* [_group_ [_command_]]
+*newgrp* [_group_|_GID_ [_command_]]
-*newgrp* [*-c* _command_] [_group_]
+*newgrp* [*-c* _command_] [_group_|_GID_]
== DESCRIPTION
-*newgrp* changes the group identification of its caller, analogously to *login*(1). The same person remains logged in, and the current directory is unchanged, but calculations of access permissions to files are performed with respect to the new group ID.
+*newgrp* changes the group identification of its caller to the group specified either as a _name_ or _GID_, analogously to *login*(1).
+The same person remains logged in, and the current directory is unchanged, but calculations of access permissions to files are performed with respect to the new group ID.
If no group is specified, the GID is changed to the login GID.
#include "nls.h"
#include "pathnames.h"
#include "xalloc.h"
+#include "pwdutils.h"
static char *xgetpass(FILE *input, const char *prompt)
{
{
FILE *out = stdout;
fputs(USAGE_HEADER, out);
- fprintf(out, _(" %s <group> [[-c] <command>]\n"), program_invocation_short_name);
+ fprintf(out, _(" %s <group|GID> [[-c] <command>]\n"), program_invocation_short_name);
fputs(USAGE_SEPARATOR, out);
fputs(_("Log in to a new group; optionally executing a shell command.\n"), out);
err(EXIT_FAILURE, _("setgid() failed"));
} else {
errno = 0;
- if (!(gr_entry = getgrnam(argv[optind++]))) {
+ if (!(gr_entry = ul_getgrp_str(argv[optind++], NULL))) {
if (errno)
err(EXIT_FAILURE, _("no such group"));
else
'newgrp',
'login-utils/newgrp.c',
include_directories : includes,
+ link_with : [lib_common],
dependencies : [lib_crypt],
install_dir : usrbin_exec_dir,
install_mode : 'rwsr-xr-x',