Skip to content

Commit

Permalink
tcb_(un)convert: Check for UID == 0 before performing.
Browse files Browse the repository at this point in the history
Signed-off-by: Björn Esser <[email protected]>
  • Loading branch information
besser82 committed Dec 22, 2024
1 parent b6ce07b commit 237815f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
8 changes: 8 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
2024-12-22 Björn Esser <besser82 at fedoraproject.org>

tcb_(un)convert: Check for UID == 0 before performing.
* progs/Makefile: Install tcb_(un)convert with standard
executable permissions.
* progs/tcb_convert.c (main): Check for UID == 0.
* 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
4 changes: 2 additions & 2 deletions progs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ install: install-common
install-common:
$(MKDIR) -p -m 755 $(DESTDIR)$(SBINDIR)
$(MKDIR) -p -m 755 $(DESTDIR)$(MANDIR)/man8
$(INSTALL) -m 700 $(CONVERT) $(DESTDIR)$(SBINDIR)/
$(INSTALL) -m 700 $(UNCONVERT) $(DESTDIR)$(SBINDIR)/
$(INSTALL) -m 755 $(CONVERT) $(DESTDIR)$(SBINDIR)/
$(INSTALL) -m 755 $(UNCONVERT) $(DESTDIR)$(SBINDIR)/
$(INSTALL) -m 644 $(CONVERT).8 $(DESTDIR)$(MANDIR)/man8/
$(INSTALL) -m 644 $(UNCONVERT).8 $(DESTDIR)$(MANDIR)/man8/

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()) {
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()) {
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 237815f

Please sign in to comment.