Skip to content

Commit

Permalink
tcb_(un)convert: Check for UID and EUID to be 0 before proceeding.
Browse files Browse the repository at this point in the history
Ensuring the program is run with root privileges on startup is the
safer approach instead on relying that mode 0700 may prevent the
tool being run by a regular system user.

Signed-off-by: Björn Esser <[email protected]>
  • Loading branch information
besser82 authored and solardiz committed Dec 27, 2024
1 parent b6ce07b commit c96fded
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
2024-12-22 Björn Esser <besser82 at fedoraproject.org>

tcb_(un)convert: Check for UID and EUID to be 0 before proceeding.
Ensuring the program is run with root privileges on startup is the
safer approach instead on relying that mode 0700 may prevent the
tool being run by a regular system user.
* progs/tcb_convert.c (main): Check for UID and EUID to be 0 before
proceeding.
* progs/tcb_unconvert.c (main): Likewise.

2024-12-20 Björn Esser <besser82 at fedoraproject.org>

libnss_tcb: Disallow potentially-malicious user names in getspnam(3).
Expand Down
5 changes: 5 additions & 0 deletions progs/tcb_convert.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,11 @@ int main(void)
{
int status;

if (getuid() || geteuid()) {
fprintf(stderr, "Only root can do this!\n");
return 1;
}

if (lckpwdf()) {
perror("lckpwdf");
return 1;
Expand Down
5 changes: 5 additions & 0 deletions progs/tcb_unconvert.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,11 @@ int main(void)
gid_t sysgid;
int status;

if (getuid() || geteuid()) {
fprintf(stderr, "Only root can do this!\n");
return 1;
}

gr = getgrnam("sys");
if (!gr) {
fprintf(stderr, "\"sys\" group not found.\n");
Expand Down

0 comments on commit c96fded

Please sign in to comment.