Commit Graph

19 Commits

Author SHA1 Message Date
Karel Zak 1b54a74e86 lib/procutils: improve proc_is_procfs(), add test
* add delay between attempts
* zeroize errno and check for EAGAIN (like in other code)
* add small test program
   ./test_procutils --is-procfs [<dir>]

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-20 10:40:31 +01:00
Érico Rolim e411b8a63d lib/procutils: add proc_is_procfs helper.
Also add missing include in procutils.h for the definition of pid_t.
2020-11-18 14:30:50 -03:00
Karel Zak b412824db4 lib/procutils: use Public Domain for this file
It's was originally GPL, but all the current code in the file is from
me and I don't think it makes sense to use GPL here anymore. We need
to use lib/ files in LGPL as well as in GPL binaries, etc. Let's makes
things (build-system) less complicated.

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-10-06 13:15:29 +02:00
Karel Zak e8f7acb0d3 lib: use unique ifdefs for tests
Let's use unique TEST_PROGRAM_<NAME> ifdefs to make build system more
robust.

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-01-04 11:44:37 +01:00
Ruediger Meier 1a048dc5e2 lib: move fopen_at() to fileutils.h, remove at.h
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-03-07 15:36:00 +01:00
Ruediger Meier 2208b3ccb2 lib: remove openat fallback functions (include/at.h)
I have validated that we are still compatible at least back to
  - openSUSE 11.4
  - SLE 11
  - RHEL/CentOS 6
  - OSX 10.10.x, (Xcode 6.3)
  - FreeBSD 10.2

Confirmed incompatibility:
  - OSX 10.9.x, (Xcode 6.2)

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-03-07 15:33:56 +01:00
Karel Zak 0e756daeb6 lslocks: use stuff from lib/procutils
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-11-25 14:17:22 +01:00
Sami Kerola ee24ab6f1e misc: fix redundant assignment and reassignments before use [cppcheck]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-08-08 07:46:39 +01:00
Karel Zak f6c01f4eed lib/procutils: add proc_get_cmdline()
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-07-20 11:48:09 +02:00
Ruediger Meier 4f4fc8c1d0 procutils: reset errno before readdir
readdir(3p): "When the end of the directory is encountered, a null
pointer shall be returned and errno is not changed"

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2015-06-16 16:22:26 +02:00
Karel Zak 8471bc61f9 lib/procutils: check fgets() return value [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-07-17 14:11:28 +02:00
Sami Kerola 1786a9ac2b lib/procutils: notice setuid() process ownership changes
Earlier the owner of a process was determined by owner of the
/proc/<pid>/stat file.  When changes user ID privileges with setuid() the
stat file ownership is not updated, that resulted kill(1) to consider
such processes where running using same uid as the present process.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-04-26 19:04:57 +01:00
Sami Kerola 5889fbe592 lib/procutils: reset errno before strtol() call
When going through /proc the last entry made readdir() to alter errno,
which made the strtol() to think something went wrong, resulting kill(1)
tests to fail when running in --parallel mode.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-04-26 19:04:57 +01:00
Karel Zak 13377dd64a lib/procutils: add simple API to scan /proc/PID/*
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-12 17:24:14 +01:00
Karel Zak 1bb53a5435 lib/procutils: test refactoring
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-12 15:45:59 +01:00
Karel Zak ce75b60528 build-sys: fix 'make checkincludes' warnings
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-28 13:21:00 +02:00
Karel Zak 4ef2674615 lib: [procutils.c] improve robustness
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-06-20 13:58:41 +02:00
Samuel Thibault 4585ec0b29 misc: hurd build fixes
* Make blkdev_is_misaligned return 0 when BLKALIGNOFF is not available.
* Make procutils.c include c.h to get a PATH_MAX replacement.
* Provide agetty.c USE_SYSLOG, DEFAULT_VCTERM and DEFAULT_STERM
  defaults for Hurd.
* Make agetty.c only deal with OFDEL, XCASE and VSWTCH if they are
  available.

Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-06-20 12:48:35 +02:00
Karel Zak 5b1f031123 lib: [procutils.c]: add missing files. Sorry.
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-05-04 15:52:39 +02:00