Commit graph

20 commits

Author SHA1 Message Date
Jie Lu
1fe82e5cf5 policycoreutils: fix potential NULL reference in load_checks
In load_checks(), add return check for malloc() to avoid NULL reference.

Signed-off-by: Jie Lu <lujie54@huawei.com>
Acked-by: James Carter <jwcart2@gmail.com>
2023-01-11 08:40:33 -05:00
Christian Göttsche
081ac391ad policycoreutils: mark local functions static
setfiles.c:50:6: warning: no previous prototype for ‘set_rootpath’ [-Wmissing-prototypes]
       50 | void set_rootpath(const char *arg)
          |      ^~~~~~~~~~~~
    setfiles.c:67:5: warning: no previous prototype for ‘canoncon’ [-Wmissing-prototypes]
       67 | int canoncon(char **contextp)
          |     ^~~~~~~~

    newrole.c:185:5: warning: no previous prototype for ‘authenticate_via_pam’ [-Wmissing-prototypes]
      185 | int authenticate_via_pam(const char *ttyn, pam_handle_t * pam_handle)
          |     ^~~~~~~~~~~~~~~~~~~~

    run_init.c:241:5: warning: no previous prototype for ‘authenticate_user’ [-Wmissing-prototypes]
      241 | int authenticate_user(void)
          |     ^~~~~~~~~~~~~~~~~
    run_init.c:306:5: warning: no previous prototype for ‘get_init_context’ [-Wmissing-prototypes]
      306 | int get_init_context(char **context)
          |     ^~~~~~~~~~~~~~~~

    sestatus.c:38:5: warning: no previous prototype for ‘cmp_cmdline’ [-Wmissing-prototypes]
       38 | int cmp_cmdline(const char *command, int pid)
          |     ^~~~~~~~~~~
    sestatus.c:62:5: warning: no previous prototype for ‘pidof’ [-Wmissing-prototypes]
       62 | int pidof(const char *command)
          |     ^~~~~
    sestatus.c:95:6: warning: no previous prototype for ‘load_checks’ [-Wmissing-prototypes]
       95 | void load_checks(char *pc[], int *npc, char *fc[], int *nfc)
          |      ^~~~~~~~~~~
    sestatus.c:171:6: warning: no previous prototype for ‘printf_tab’ [-Wmissing-prototypes]
      171 | void printf_tab(const char *outp)
          |      ^~~~~~~~~~

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
2021-11-15 16:00:54 -05:00
Christian Göttsche
fb68d036b8 policycoreutils: use string literal as format strings
Use string literal as format string so that compilers can validate the
count and types of the inherent arguments.

    sestatus.c: In function ‘printf_tab’:
    sestatus.c:175:16: error: format not a string literal, argument types not checked [-Werror=format-nonliteral]
      175 |         printf(buf, outp);
          |                ^~~

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
2021-11-15 16:00:54 -05:00
Christian Göttsche
d8b9bd5c2a policycoreutils: free memory on lstat failure in sestatus
In case lstat(3) fails the memory is not free'd at the end of the for
loop, due to the control flow change by continue.

Found by scan-build.

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
2021-07-19 10:42:45 -04:00
bauen1
d464187c37 policycoreutils: sestatus belongs to bin not sbin
It is quite useful even to non-privileged users and doesn't require any
privileges to work, except for maybe -v.

Some tools hard code the old path, so a compatibility symlink is also
created.

Signed-off-by: Jonathan Hettwer <j2468h@gmail.com>
Acked-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2021-02-24 11:22:03 +01:00
Aleksei Nikiforov
0445e65d83 Allow installing translated man pages
Signed-off-by: Aleksei Nikiforov <darktemplar@basealt.ru>
2019-01-28 12:03:57 +01:00
Aleksei Nikiforov
e3e3873de7 Add man pages translation by Olesya Gerasimenko
Signed-off-by: Olesya Gerasimenko <gammaray@basealt.ru>
Signed-off-by: Aleksei Nikiforov <darktemplar@basealt.ru>
2019-01-28 12:03:57 +01:00
Jason Zaman
42f0376228 sestatus: include limits.h for PATH_MAX
compile fails on musl libc because it cant find PATH_MAX.

Signed-off-by: Jason Zaman <jason@perfinion.com>
2018-05-16 16:27:17 +08:00
Nicolas Iooss
20a324b591 sestatus: free process and file contexts which are checked
clang's static analyzer reports a potential memory leak because the
buffers allocated in pc and fc are not freed in main(), in sestatus.c.
Free these buffers properly.

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2018-04-25 10:09:13 -07:00
Nicolas Iooss
0f99a3126c sestatus: resolve symlinks in path when looking for a process
"sestatus -v" uses /proc/$PID/exe symbolic link in order to find the
context of processes present in /etc/sestatus.conf. For example, this
file includes "/usr/sbin/sshd".

On Arch Linux, /bin, /sbin and /usr/sbin are symbolic links to /usr/bin,
so sshd process is seen as "/usr/bin/sshd" instead of "/usr/sbin/sshd".
This causes "sestatus -v" to show nothing in "Process contexts:" for
sshd, agetty, etc.

Use realpath() to resolve any symlink components in program paths
defined in /etc/sestatus.conf. This makes "sestatus -v" show the
expected result:

    Process contexts:
    Current context:                sysadm_u:sysadm_r:sysadm_t
    Init context:                   system_u:system_r:init_t
    /sbin/agetty                    system_u:system_r:getty_t
    /usr/sbin/sshd                  system_u:system_r:sshd_t

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2018-04-25 10:09:13 -07:00
Marcus Folkesson
6b901a4fb8 policycoreutils: build: follow standard semantics for DESTDIR and PREFIX
Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
2018-02-14 20:02:01 +01:00
Jason Zaman
15f2740733 Makefiles: override *FLAGS and *LIBS
There were several places in the makefiles where LDLIBS or CFLAGS were
supposed to include options to build. They were missing the override
keyword so would be skipped if these vars were set on the make cmdline.
Add the override directive to fix this.

Signed-off-by: Jason Zaman <jason@perfinion.com>
2017-06-20 12:15:04 -04:00
Christian Göttsche
3376ac498e sestatus: show checkreqprot status
Show the current active checkreqprot state in sestatus
2017-05-08 12:44:12 -04:00
Jason Zaman
fcb5d5cc72 Makefiles: drop -L/-I to system paths
The toolchain automatically handles them and they break cross compiling.

LDFLAGS should also come before object files, some flags (eg,
-Wl,as-needed) can break things if they are in the wrong place)

Gentoo-Bug: https://bugs.gentoo.org/500674

Signed-off-by: Jason Zaman <jason@perfinion.com>
2017-04-25 08:27:05 -04:00
Laurent Bigonville
84e085847d policycoreutils: Fix cases where hyphen were used as minus sign in manpages
And also other minor formating issues
2013-10-16 15:12:10 -04:00
Simon Ruderich
002280edbb policycoreutils: Allow overriding CFLAGS in setfiles and sestatus Makefiles
This is required to be able to pass hardening flags in Debian.
2013-10-16 15:03:16 -04:00
Eric Paris
5c0d7113de policycoreutils: sestatus: rewrite to shut up coverity
The code did:

len = strlen(string);
new_string = malloc(len);
strncpy(new_string, string, len - 1)

Which is perfectly legal, but it pissed off coverity because 99/100
times if you do new_string = malloc(strlen(string)) you are doing it
wrong (you didn't leave room for the nul).  I rewrote that area to just
use strdup and then to blank out the last character with a nul.  It's
clear what's going on and nothing looks 'tricky'.  It does cost us 1
byte of heap allocation.  I think we can live with that to have safer
looking string handling code.

Signed-off-by: Eric Paris <eparis@redhat.com>
2013-02-05 20:21:51 -05:00
Richard Haines
3e870d7c9b policycoreutils: sestatus: Updated sestatus and man pages.
sestatus has been modified to present additional information: SELinux root
directory, MLS flag and the deny_unknow flag. The man page has been updated
to reflect these changes and an sestatus.conf(5) man page has also been added.

Signed-off-by: Richard Haines <richard_c_haines@btinternet.com>
Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-12-05 16:10:38 -05:00
Eric Paris
468bff0952 tree: Makefiles: syntax, convert all ${VAR} to $(VAR)
This is purely personal preference.  Most of the Makefiles use $() for
Makefile variables, but a couple of places use ${}.  Since this obscured
some later Makefile changes I figured I'd just make them all the same up
front.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-11-02 15:37:08 -04:00
Joshua Brindle
13cd4c8960 initial import from svn trunk revision 2950 2008-08-19 15:30:36 -04:00