Live data from Hacker News

How do groups work on Linux?

jvns.ca

51–60 of 68 posts

Re: How do groups work on Linux?

#51
post #20

The book she mentions, "The Linux Programming Interface," sounds pretty useful, but it's seven years old at this point. Does anyone know how much has changed or if there's a new version coming any time soon? Seems like it's worth $70 but the age has me concerned. I'm sure the basics, like the things this article is about, haven't changed, but I bet all the stuff around cgroups would be useful for how setgid works wit…

[deleted]

Re: How do groups work on Linux?

#52
post #31
post #28

Earlier quoted context omitted.

So why did you mentation "Ext2/3/4 and XFS" if filesystem doesn't matter?

I don't see what you don't understand. I demonstrated that on FreeBSD created file inherits the group of its parent directory even without SGID, i.e. that FreeBSD exhibits BSD semantics. I also added that if you can have BSD semantics on Ext2/3/4 and XFS if you mount them under Linux with appropriate options.

You’re getting downvoted a bunch here, but I believe your basic point is valid. To take it back to the GP: SGID bit and other such OS and/or filesystem specific semantics are not the best measurement of someone’s overall UNIX understanding.

Now, IMO asking someone if they understand what the difference is between chmod VS chmod is and why it exists is a bit more telling, because this touches down on what interface most unix filesystems try to present and also how they’re implemented to a degree.

The specifics on any given system are just a manpage away but the general understanding only really comes from having absorbed some actual unix interactions.

And certainly knowing more than just Linux should get one bonus points...

Re: How do groups work on Linux?

#53

Earlier quoted context omitted.

I use this as a basic indicator of someone's Unix competency. Not as a straight binary thing, but if I'm talking to someone (interviewing or maybe debugging something) I've found that if you know about setgid/setuid you have probably been interested enough to know what you are doing.

I've worked around this without knowing about setgid ... It's funny how easily I suffer tiny papercuts that way, it should be obvious "there's a better way".

[deleted]

Re: How do groups work on Linux?

#54
post #20

The book she mentions, "The Linux Programming Interface," sounds pretty useful, but it's seven years old at this point. Does anyone know how much has changed or if there's a new version coming any time soon? Seems like it's worth $70 but the age has me concerned. I'm sure the basics, like the things this article is about, haven't changed, but I bet all the stuff around cgroups would be useful for how setgid works wit…

The big thing I've found missing is discussion of containerization primitives, e.g. cgroups. The other Linux namespaces are discussed where appropriate, but in 2017 it would be nice to have a section on all these together.

Re: How do groups work on Linux?

#55
post #47
post #42

Earlier quoted context omitted.

explain?

shabble@host:~$ cp /bin/chmod /tmp/chmoo shabble@host:~$ chmod 600 /tmp/chmoo shabble@host:~$ ll /tmp/ch* -rw------- 1 shabble shabble 59K Nov 21 17:15 /tmp/chmoo shabble@host:~$ /tmp/chmoo -bash: /tmp/chmoo: Permission denied shabble@host:~$ /lib64/ld-linux-x86-64.so.2 /tmp/chmoo /tmp/chmoo: missing operand Try '/tmp/chmoo --help' for more information.

Well, that's a new one on me. I'd just have 'cat'ted the chmod executable onto some other executable, which keeps the permissions.

Re: How do groups work on Linux?

#56
post #44

Earlier quoted context omitted.

I'm not sure what you aren't understanding. Directories are just a type of file, so that's not wrong, the dir/file is owned by the `awesome` group, and the group permissions are `r--` so the group can indeed read it.

Or one could apply Occam's razor and admit that "d" was a typo.

Of course, that's a much more likely scenario. I was attempting to show that the line was not completely nonsensical is all.

Re: How do groups work on Linux?

#57
post #36

Regarding setuid, this is why when you run programs like ping(8) it doesn't require root access to open a raw socket. ping's setuid is set so upon execution it executes as root since ping is owned by root and then calls setuid(getuid()) to run as the intended user.

In some distributions, ping is now no longer setuid, but instead setcap with CAP_NET_RAW to narrow down the privileges gained.

Re: How do groups work on Linux?

#58
post #9

Some highlighted words do not appear using Firefox 57 on my Ubuntu 16.04.3, like the word "julia" at the third line. It's OK with Chromium. EDIT: Seems a Firefox related bug, i noticed this strange behavior with other websites inc. Stack Overflow since then. Will investigate asap.

i am also using firefox 57 on ubuntu 16.04.3 and it looks fine to me. it must be something with your specific setup.

Re: How do groups work on Linux?

#59
post #42

Earlier quoted context omitted.

explain?

I'm a little surprised some smartypants hasn't come along and added a check to ld to prevent this from working, probably for "security" reasons. I've known about this trick for a long time, but I've always thought its days were numbered. Another way to solve the problem: scp unfuckedhost:/bin/chmod . ./chmod (stuff)

This is my go-to method for doing that. Years ago, in the 90s, I used that trick (with ftp) to overwrite a custom login script used to "prevent" users from logging in. You'd login and it would spit out like "You are not allowed to login!" and then immediately log you out. Well, ftp (this is before sftp or scp) let me copy over that. This was actually one of the computers used by the newspaper in the next town over. I'm still shocked actually that the worst I ever got from the sysadmin there was a stern phone call.

Re: How do groups work on Linux?

#60
post #4

Also "newgrp" can be used for join "new" groups without re-login.

And here I've been using `su - $ME` all this time. Thanks!

Worth noting that it's not functionally all that different in that newgrp spawns a new shell under the current one; aside from the - creating a login shell anyway - but you can do that with newgrp too
Post reply on HN