Score:5

How to build "su" from sources?

gw flag

Try to build custom "su" on Ubuntu 20.04, but start from original sources for test (without changes). Run

apt-get source login

I got shadow-4.8.1 dir. Run

./configure
make

and try run

src/su testuser

Its does not works! Auth fail error. Run original OS binary:

/usr/bin/su testuser

and its works fine! Wtf?

I think some modules/params is missing in build process.

Going to buildlog of shadow package.

https://launchpad.net/ubuntu/+source/shadow/1:4.11.1+dfsg1-2ubuntu1/+build/23780688

and see next ./configure string

./configure --build=x86_64-linux-gnu --prefix=/usr --includedir=\${prefix}/include --mandir=\${prefix}/share/man --infodir=\${prefix}/share/info --sysconfdir=/etc --localstatedir=/var --disable-silent-rules --libdir=\${prefix}/lib/x86_64-linux-gnu --runstatedir=/run --disable-maintainer-mode --disable-dependency-tracking --disable-shared --without-libcrack --mandir=/usr/share/man --with-libpam --enable-shadowgrp --enable-man --disable-account-tools-setuid --with-group-name-max-length=32 --without-acl --without-attr --without-su --without-tcb 

See there:

--without-su

Try this ./configure string and its really make all binaries without "su". Try replace it on

--with-su

And new binary dont work too. Auth fail. :(

Two questions about it.

  1. Where can i find buildlog of original "su"?
  2. Why fresh builded "su" cant see real OS user, which exists in /etc/shadow|passwd?
hr flag
FYI the default implementation of su in Ubuntu 20.04 is provided by the util-linux package
Score:9
om flag

Nothing is failing in the compilation process. But the su that you compiled is owned by your user, and does not have the set uid bit set, which means it executes as your user.

Your user does not have capability to switch to other user id's. That's reserved for root.

If you run ls -l /usr/bin/su, you'll see that it's owned by root and has the suid bit set:

$ ls -l /usr/bin/su
-rwsr-xr-x 1 root root 55480 Apr  1 21:16 /usr/bin/su

You can fix this by running chown root:root /path/to/your/su to make it owned by root, and chmod 4755 /path/to/your/su to make it setuid.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.