Commit Graph

22 Commits

Author SHA1 Message Date
Colin Watson
26ae657950 pwdx: fails when run in a nonexistent locale
pwdx rather mysteriously fails with "invalid process id" when run in a
nonexistent locale (e.g. "LC_ALL=foo pwdx $$").  This is because it
fails to obey the documented calling sequence for strtol - that is, set
errno to 0 before the call - and thus the errno from the setlocale
failure bleeds over into its check for whether strtol failed.

References: http://bugs.debian.org/718766

Signed-off-by: Craig Small <csmall@enc.com.au>
2013-08-05 20:52:22 +10:00
Rainer Müller
042776e04c configure: check for program_invocation_name
For portabiliy, check for program_invocation_name during configure and
define HAVE_PROGRAM_INVOCATION_NAME accordingly. Use of this symbol is
now enclosed with the appropriate #ifdef block.

The symbol program_invocation_name is only used for error message
handling using error(), so it's safe to omit this if it is not
available.
2013-03-20 16:32:06 +01:00
Andrej Kruták
138701c499 Fix pwdx argument parsing
On some architectures/gcc's, the pwdx tool doesn't compile right
because of bad type of a variable. Afterwards pwdx can't be
persuaded to work. Use int as the type, like the other tools
(like pgrep) do.

Signed-off-by: Craig Small <csmall@enc.com.au>
2012-06-14 22:33:49 +10:00
Sami Kerola
52269d22f3 all: check stdout and stderr status at exit
If stream status is not checked at the end of execution below problem
would not report error, or non-zero exit code.  The uptime is just an
example same was true with all commands of the project.

$ uptime >&- ; echo $?
uptime: write error: Bad file descriptor
1
$ uptime >/dev/full ; echo $?
uptime: write error: No space left on device
1

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-03-23 15:57:53 +01:00
Sami Kerola
ce61089059 docs: clarification to license headers in files
Add license header to all files.  The summary of licensing is below,
taken from Craig Small's email which is referred in commit message
tail.

sysctl and pgrep are GPL 2+
The rest is LGPL 2.1+

Reference: http://www.freelists.org/post/procps/Incorrect-FSF-address-in-the-license-files,8
Bug-Redhat: https://bugzilla.redhat.com/show_bug.cgi?id=797962
CC: Craig Small <csmall@enc.com.au>
CC: Jaromir Capik <jcapik@redhat.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-03-03 18:41:11 +11:00
Sami Kerola
1e489c7bc9 pwdx: fix compiler warning
pwdx.c:96:3: warning: ISO C90 forbids variable length array 'buf' [-Wvla]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-03-03 18:35:35 +11:00
Sami Kerola
c686e4c4dc pwdx: free memory before exit
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-02-05 20:44:39 +01:00
Mike Frysinger
afaf698896 use helpers from c.h
A few files still use the C library helpers from err.h, so migrate
them to the local c.h helpers.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2012-01-24 08:55:05 +01:00
Sami Kerola
9d47cb0c38 pwdx: re-create invalid process id check
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-01-08 21:29:51 +01:00
Craig Small
fb11e1fe0a Changed the err and warns to macros
err and warn are BSD format but they are not recommended by library
developers.  However their consiseness is useful!

The solution is to use some macros that create xerr etc which then
just map to the error() function.  The next problem is error() uses
program_invocation_name so we set this to program_invovation_short_name

This is a global set but seems to be the convention (or at least errors
are on the short name only) used everywhere else.
2012-01-03 18:48:43 +11:00
Sami Kerola
2c8b3a7857 pwdx: write errors to stderr
Includes also magic number removal (return value 1 to EXIT_FAILURE),
and proper null assignment to end of string.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-12-20 17:30:54 +01:00
Sami Kerola
0022b6ec5d nls: improve translations and provide translator help comments
Reference: http://www.freelists.org/post/procps/backporting,1
Reported-by: Jim Warner <james.warner@comcast.net>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-12-20 17:30:54 +01:00
Sami Kerola
c862a4caa5 nls: add functions which take translations to be used
Add the following three functions to most of the commands.

setlocale (LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);

Reference: http://www.freelists.org/post/procps/backporting,1
Reported-by: Jim Warner <james.warner@comcast.net>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-12-20 17:30:53 +01:00
Sami Kerola
e9f7392d31 pwdx: add gettext support
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-12-20 17:17:04 +01:00
Sami Kerola
4f7b9c661b pwdx.c: new usage & fix coding style
Coding style fixed and new help output.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-12-20 17:17:02 +01:00
Daniel Novotny
5d29bfedc8 pwdx & libprocps-ng: Hurd does not have MAX_PATH defined
A patch from Debian.

Bug-Redhat: https://bugzilla.redhat.com/show_bug.cgi?id=485243
Bug-Debian: http://bugs.debian.org/588677
Backported-by: Sami Kerola <kerolasa@iki.fi>
2011-12-18 22:30:00 +11:00
Jim Warner
3f75390563 redhat analysis: pwdx 2011-10-15 08:26:28 +02:00
Werner Fink
9564bfc6f0 Fix potential bufferoverflow in pwdx
Fix potential bufferoverflow in pwdx
 Novell bugzilla entry 78074

Signed-off-by: Werner Fink <werner@suse.de>
2011-01-18 16:15:15 +01:00
albert
ac23e47c3e pwdx: buffer overflow fixed -- thanks Ulf Harnhammar 2006-06-17 05:01:17 +00:00
albert
c03b9f6deb fix buffer overflow 2005-10-30 23:52:35 +00:00
albert
29cbc63561 fputs instead of fprintf 2005-10-30 23:45:47 +00:00
albert
92ba425ed6 new pwdx command 2004-10-16 07:59:02 +00:00