Commit Graph

43 Commits

Author SHA1 Message Date
Karel Zak 777fe9f512 newgrp: fix memory leak [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-06-11 15:10:22 +02:00
Egor Chelak 1b10fa0ef7 cast NULL to char * when using execl
When calling variadic functions, NULL must be explicitly cast to a
desired type.
This is noted in the exec(3) manpage.

The call in newgrp.c was changed for consistency.

Signed-off-by: Egor Chelak <egor.chelak@gmail.com>
2020-10-29 19:49:07 +02:00
Karel Zak 2c308875a7 misc: consolidate version printing and close_stdout()
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-04-16 15:14:13 +02:00
Karel Zak 856fcfd104 newgrp: use errexec()
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-02-01 15:41:23 +01:00
Ruediger Meier f45f3ec34a misc: consolidate macro style USAGE_HELP_OPTIONS
changed in include/c.h and applied via sed:

  sed -i 's/fprintf.*\(USAGE_MAN_TAIL.*\)/printf(\1/' $(git ls-files -- "*.c")
  sed -i 's/print_usage_help_options\(.*\);/printf(USAGE_HELP_OPTIONS\1);/' $(git ls-files -- "*.c")

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-29 16:54:33 +02:00
Ruediger Meier b1a294c448 misc: introduce print_usage_help_options()
Consolidate --help and --version descriptions. We are
now able to align them to the other options.

We changed include/c.h. The rest of this patch was
generated by sed, plus manually setting the right
alignment numbers. We do not change anything but
white spaces in the --help output.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-27 12:26:19 +02:00
Ruediger Meier 86be6a32d3 misc: cosmetics, remove argument from usage(FILE*)
This patch is trivial and changes nothing, because
we were always using usage(stdout)

Now all our usage() functions look very similar. If wanted we
could auto-generate another big cosmetical patch to remove all
the useless "FILE *out" constants and use printf and puts
rather than their f* friends. Such patch could be automatically
synchronized with the translation project (newlines!) to not
make the translators sick.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-26 14:38:24 +02:00
Sami Kerola 875834381d newgrp: use libc explicit_bzero() when it is available
This currently new function will be part of glibc 2.25.

Reference: https://sourceware.org/git/?p=glibc.git;a=commit;h=ea1bd74defcf9d5291d14972e63105168ca9eb4f
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-01-16 12:30:09 +01:00
Karel Zak 677ec86cef Use --help suggestion on invalid option
The current default is to print all usage() output. This is overkill
in many case.

Addresses: https://github.com/karelzak/util-linux/issues/338
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-12-19 13:13:34 +01:00
Ruediger Meier bbbf2aa853 newgrp: rename memset_s()
It's already defined in OSX standard c library.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-29 13:04:59 +01:00
Filipe Brandenburger 94757eceb1 scriptreplay/newgrp: use signed int to store return of getopt_long
Signed-off-by: Filipe Brandenburger <filbranden@google.com>
2016-01-07 12:47:41 +01:00
Benno Schulenberg 451dbcfae1 textual: add a docstring to most of the utilities
This adds a concise description of a tool to its usage text.

A first form of this patch was proposed by Steven Honeyman
(see http://www.spinics.net/lists/util-linux-ng/msg09994.html).

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-01-06 11:27:38 +01:00
Sami Kerola 1fd15f04b3 newgrp: set function arguments read-only when possible
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-01-05 22:53:01 +00:00
Sami Kerola 51c52acfb1 newgrp: move shell determination closer where it is used
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-01-05 22:53:01 +00:00
Sami Kerola 477135dfec newgrp: simplify if else clauses
The 'if' clauses that have termination as either of the control flow
results will never need 'else'.  Making the termination to happen true
flow is enough.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-01-05 22:53:01 +00:00
Sami Kerola 7d2600e2d0 docs: update deprecation banners
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-10-01 12:33:11 +02:00
Benno Schulenberg ee7ea5c85e textual: use a somewhat clearer and more standard failure message
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-10-01 09:37:04 +02:00
Sami Kerola 453fc7165d textual: share crypt() error message in sulogin and newgrp
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-09-19 19:31:03 +01:00
Sami Kerola 8f663a674d newgrp: avoid use of obsolete getpass() function
Read a password from user with termios, and once the password data is no
longer needed ensure it gets overwrote before unallocating memory.

Reference: http://man7.org/linux/man-pages/man3/getpass.3.html
Reference: https://www.securecoding.cert.org/confluence/display/seccode/MSC06-C.+Beware+of+compiler+optimizations
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-09-19 19:31:03 +01:00
Sami Kerola c829aebc39 newgrp: use libc function to read gshadow if it is available
The glib versionf of getsgnam() is using /etc/nsswitch.conf, allowing the
group passwords to come from external database.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-09-19 19:31:02 +01:00
Sami Kerola 5fb01f4331 newgrp: use xstrdup to check allocation succeeded
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-04-05 13:55:50 +02:00
Sami Kerola 07ff972eb6 translation: unify exec error messages
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-02-06 11:51:17 +01:00
Benno Schulenberg b50945d4ac textual: spell and encode the name of Arkadiusz Miśkiewicz correctly
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2013-02-06 11:15:02 +01:00
Karel Zak 19a1ca6c0d newgrp: more robust crypt() usage
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-02-01 18:00:52 +01:00
Sami Kerola 439cdf1e24 login-utils: verify writing to streams was successful
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-04-04 19:58:34 +02:00
Sami Kerola ba0c903004 docs: add deprecation comments
Markup deprecation to command header to avoid people wasting time in
fixing these utilities.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-03-18 14:28:03 +01:00
Karel Zak c6f23b3ba1 login: (and chsh) make pw_shell usage more robust
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-02-02 14:13:45 +01:00
Karel Zak 1f19513b72 newgrp: fix possible FILE leak on error
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-02-01 13:37:57 +01:00
Sami Kerola b7cfaaf85b newgrp: fix coding style
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-11-29 17:58:00 +01:00
Sami Kerola e947e27360 newgrp: add version and help options
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-11-23 21:37:19 +01:00
Fabian Groffen eb76ca98b0 build-sys: provide alternatives for err, errx, warn and warnx
Solaris lacks err, errx, warn and warnx.  This also means the err.h header
doesn't exist.  Removed err.h include from all files, and included err.h from
c.h instead if it exists, otherwise alternatives are provided.

Signed-off-by: Fabian Groffen <grobian@gentoo.org>
2011-02-14 17:45:24 +01:00
Fabian Groffen 0aeb57aca3 build-sys: improve check for crypt
Check for crypt.h existence, and use it if available over using unistd.h
for which a certain feature level has to be set to export a definition
for crypt.  On Solaris this set causes a standards conflict in the
headers, because at the time of this check C99 mode is already enabled,
which implies certain standards non-compatible with _XOPEN_SOURCE.

 92  #define _XOPEN_SOURCE
 93  #include <unistd.h>

configure:16259: gcc -std=gnu99 -c -g -O2  conftest.c >&5
In file included from /usr/include/unistd.h:18,
                 from conftest.c:93:
/prefix/gentoo/usr/lib/gcc/i386-pc-solaris2.10/4.4.5/include-fixed/sys/feature_tests.h:341:2: error: #error "Compiler or options invalid for pre-UNIX 03 X/Open applications and pre-2001 POSIX applications"

configure.ac: improve crypt check
login-utils/my_crypt.h: replace old GNU_LIBRARY check with autoconf
define for crypt.h

[kzak@redhat.com: - remove my_crypt.h]

Signed-off-by: Fabian Groffen <grobian@gentoo.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-01-17 16:32:39 +01:00
Marek Polacek 1fa30199c6 newgrp: Use err() and EXIT_*
Use err() or errx() where appropriate.  Also use EXIT_* macros instead
of 0/1.  All error messages shall start with lowercase.

Signed-off-by: Marek Polacek <mmpolacek@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-12-02 17:15:51 +01:00
Karel Zak ad564eadf9 newgrp: use c.h, remove tailing whitespace
Signed-off-by: Karel Zak <kzak@redhat.com>
2009-10-16 01:38:29 +02:00
Karel Zak 66a9411eb0 newgrp: add support for /etc/gshadow
The original newgrp command doesn't expect group pasword in /etc/gshadow
although almost all distributions use this file (and the gpasswd command).

The newgrp from util-linux is deprecated and better is use shadow-utils only.
Unfortunately, shadow-utils are broken too (see RH version where is bugfix).
In this case it's better fix util-linux version at least...

Signed-off-by: Karel Zak <kzak@redhat.com>
2007-03-21 23:07:25 +01:00
Karel Zak ac70067ae6 newgrp: check result from getgrnam() more carefully
Signed-off-by: Karel Zak <kzak@redhat.com>
2007-03-21 17:29:20 +01:00
Karel Zak 48d7b13a1e Imported from util-linux-2.13-pre1 tarball. 2006-12-07 00:26:54 +01:00
Karel Zak c07ebfa1e0 Imported from util-linux-2.11b tarball. 2006-12-07 00:25:46 +01:00
Karel Zak 66ee8158b6 Imported from util-linux-2.10s tarball. 2006-12-07 00:25:44 +01:00
Karel Zak 7eda085c41 Imported from util-linux-2.9v tarball. 2006-12-07 00:25:39 +01:00
Karel Zak 2b6fc908bc Imported from util-linux-2.8 tarball. 2006-12-07 00:25:35 +01:00
Karel Zak fd6b7a7ffc Imported from util-linux-2.7.1 tarball. 2006-12-07 00:25:34 +01:00
Karel Zak 6dbe3af945 Imported from util-linux-2.2 tarball. 2006-12-07 00:25:32 +01:00