I can't remove administrator rights

I think we need to talk about some fundamentals. Let's start with a little point:
In Linux, for example, initially the user cannot enter another user's directory
In general, that statement is not true: Even in various Linux distributions, it depends on how the user's directory permissions are set (as others have already explained). That in turn depends on the default of how the Linux distribution configures new user's directories. I agree with previous posters that Ubuntu (and Debian) seem to default to permissions being restricted today. This is an example from a Raspbian system:
Code:
ls -lF /home/
total 12
drwxr-xr-x  3 electrician  electrician 4096 Jan 11 12:14 electrician/
drwxr-xr-x  3 nobody       nogroup     4096 Jan 11 12:14 nobody/
drwx------ 17 plumber      plumber     4096 Jun 22 10:40 plumber/
User "plumber" was created using the standard adduser tools during install of the system; I hand-added the "nobody" and "electrician" accounts by hand later.

Second point: You talk about "enter another user's directory". What do you mean by "enter"? Do you mean "read a directory"? Do you mean "cd into it"? Do you mean "read the files inside the directory"? The permission systems used by "modern" operating systems (pretty much all creates since the 1970s, with the exception of the original Windows with its FAT file system) are much more complex than "allowing to enter". The answers to the three questions can easily be different.

And one more point: It seems you want to change the system you administer so that no user can see (the name and attributes) or read the files of another user. In terms of permissions, that means that the group and other permissions of directories and files are set to not contain the R and X flags. You can initially accomplish that by setting the initial permissions of the user's home directories to RWX------, as in the plumber example above. But nothing prevents your users from changing that themselves. I can trivially do "chmod a+rwx ..." on my own files, and now everyone that has access to that file system can read them. Are you interested in preventing that too? If yes, you'll need some technologies that are more complex than standard Unix file system permissions.
 
I can trivially do "chmod a+rwx ..." on my own files, and now everyone that has access to that file system can read them. Are you interested in preventing that too? If yes, you'll need some technologies that are more complex than standard Unix file system permissions.
All you need is a flie monitor daemon that has been configured to silently change those bits. 😈
 
All you need is a flie monitor daemon that has been configured to silently change those bits. 😈
Well, I like the purple devil. Because doing this is devilishly difficult, and will make someone purple in the face. If the daemon runs asynchronously (for example once every minute it scans the whole file system), it is lacking ACID properties, and there will be a race condition window during which the files are not protected. By the way, scanning a large file system every minute is somewhere between insane and impossible; on my home machine (3TB home file system, about half full, with perhaps a quarter million files) it takes about 4 minutes to check the attributes (including permissions) of all files.

Doing it synchronously is not possible in normal open-source file system, since they lack policy engines, or APIs to connect outboard checkers. I don't think it can be prevented with (NFS- or Windows-) ACLs, but I'm not 100% sure (I'm not a super expert in the use of ACLs). It might be possible to get very close by using audit events, but I don't know whether UFS or ZFS support realtime audit.
 
I can trivially do "chmod a+rwx ..." on my own files
I have a bunch of misfits roaming our systems that constantly chmod -R 777 their entire home directory 👿
Oh, and they also litter files with usernames and passwords 😭
 
To quote Michael Lucas, from Absolute OpenBSD 2nd Ed:
Some users will do their best to push the limits of their access, for no other reason than to see if they can outsmart you. There users are best managed with a combination of careful configuration, administrative policy, and a cricket bat.
 
Oh, and they also litter files with usernames and passwords
yeah, that kind of stupidity is painfully common. Backup systems do sweep those up and propagate them. And then people complain about 'leaked passwords!', when they did that to themselves to begin with, and won't admit to that. Just try explaining to your boss why that is a bad idea! Bosses don't want to be taught, much less to be led to a realization that they did something moronic, esp. if their own job/promotion is on the line.
 
On ubuntu 24.04 it's because the user home directory created by adduser has no "other" permissions, basically what you get if you run the command SirDice has in #9.

It was not always this way, typical home directory permission was other having read (r) and execute (x).
There is a "-M" option that sets the mode on the created home directory 0750 gives user rwx, group=rx, other=none, you may also be able to configure it globally in

OP it sounds like you are talking about files on the FreeBSD server, is that correct? There are multiple user accounts on that server with home directories?
If so I think a more correct solution is to have someone with sudo/su privileges set at least your user directory to mode 0750. Not sure if you can do that, it would be login to your home directory then cd .. to /home and chmod -R o-rwx /home/yourusername. Not sure if that would modify something in /home or just on your /home/username
I don't know about FreeBSD, but about 5 years ago I changed the rights on CentOS 6, after which some programs stopped running because they were installed with different rights and they demanded strictly defined rights .Had to restore default rights. And in Centos, a user with his rights cannot go to another user's directory. Only with root rights. So I better move my files to /root
 
I don't know about FreeBSD, but about 5 years ago I changed the rights on CentOS 6, after which some programs stopped running because they were installed with different rights and they demanded strictly defined rights .Had to restore default rights.
I don't know what you mean when you say "rights". In Unix (which includes BSD and Linux, in particular various distributions such as CentOS), there are no "rights" that a user has. Except for two: A user is either root (the technical definition of that is that they have UID zero, not whether their username is root), or they are not. And they are either a member of the wheel group (the group with GID zero, on most Linux distributions that's called the root group, but again the name doesn't matter, the numeric GID does), or they are not.

On the other hand, directories and files have permissions. Not rights.

What are you actually talking about when you say "rights"?

And in Centos, a user with his rights cannot go to another user's directory. Only with root rights. So I better move my files to /root
That is neither specific to CentOS, nor to the root directory. I can trivially create a directory /home/bob, the home directory of user bob, which no other users can read, and therefore they can't find files in it. All I need to do is to set the permissions of /home/bob to be 700 (a.k.a. rwx------).

And matter-of-fact, while most Unix versions by default make the /root directory (the home directory of the root user) not readable (meaning permissions for it are 700 = rwx------), that is not necessary. On my home machine for example, the permissions for /root at 755 = rwxr-xr-x, so any user can find files in there. I have done that completely deliberately, and it is not in any way unsafe.

I do get the feeling that you don't quite know how permissions work in Unix.
 
All you need is a flie monitor daemon that has been configured to silently change those bits. 😈
Well, I like the purple devil. Because doing this is devilishly difficult, and will make someone purple in the face. If the daemon runs asynchronously (for example once every minute it scans the whole file system), it is lacking ACID properties, and there will be a race condition window during which the files are not protected. By the way, scanning a large file system every minute is somewhere between insane and impossible; on my home machine (3TB home file system, about half full, with perhaps a quarter million files) it takes about 4 minutes to check the attributes (including permissions) of all files.

Doing it synchronously is not possible in normal open-source file system, since they lack policy engines, or APIs to connect outboard checkers. I don't think it can be prevented with (NFS- or Windows-) ACLs, but I'm not 100% sure (I'm not a super expert in the use of ACLs). It might be possible to get very close by using audit events, but I don't know whether UFS or ZFS support realtime audit.
Something like sysutils/inotify-tools could help, but for large directory trees/lot of files multiple instances should be used.
 
I don't know about FreeBSD, but about 5 years ago I changed the rights on CentOS 6, after which some programs stopped running because they were installed with different rights and they demanded strictly defined rights .Had to restore default rights. And in Centos, a user with his rights cannot go to another user's directory. Only with root rights. So I better move my files to /root
Yeah, OP does need to understand the permissions system on UNIX better. fmc000 was right about that.

BTW, moving files to /root is a bad idea.
And in Centos, a user with his rights cannot go to another user's directory. Only with root rights.
So what's the problem? Files in a user's directory need to be safe from other users' mistakes. That is a sensible default.
 
So what's the problem? Files in a user's directory need to be safe from other users' mistakes. That is a sensible default.
I think the "problem" is that by default FreeBSD gives "o=rx" permissions on user home directory in the adduser command, which has been the default in all *nixes until recently.
Not sure when it happened but Ubuntu 18.04 created home directories with 0755, in 24.04 they are created with 0750. I don't have a 22.04 system to check, but some duck duck go implies Ubuntu changed it around 21.04. I can imagine that CentOS et al may have changed around the same time.

I don't think it's about understanding permissions I think it's more the defaults that the adduser command used, they changed over time and the defaults are different between FreeBSD and Linux-en.
 
I think the "problem" is that by default FreeBSD gives "o=rx" permissions on user home directory in the adduser command, which has been the default in all *nixes until recently.
Maybe this in adduser(8)?
Code:
     -M mode
             Create the home directory with permissions set to mode, modified
             by the current umask(2).
 
Well, in FreeBSD, at least, there's a way to strip a given user of admin privileges with pw(8):
Code:
pw groupmod -n wheel -d user 
pw groupmod -n operator -d user

This will remove user from wheel and operator groups. Membership in those groups is required if a user is to be able to access admin privileges (via su(1)). Well, speaking OP's language, membership in wheel and operator groups are what it takes to have "admin rights". Gotta think about things in forward AND reverse.
 
Maybe this in adduser(8)?
Code:
     -M mode
             Create the home directory with permissions set to mode, modified
             by the current umask(2).
If only certain users should have certain user creation configurations, they require individual settings. For a non-default, custom general user creation configuration, adduser(8) gives the possibility to create a /etc/adduser.conf file.

The config file can be created by calling adduser -C and answering the options settings.

I forgot to mention this in my post # 23
 
T-Aoki T-Daemon Yep both work, I think I referenced both previously. I think the OP issue is adduser on FreeBSD works differently from Linux in this area.

To me this is interesting exercise:
Linux changed the default value; from a security POV the change makes sense. But it only affects systems with multiple user accounts that actually have home directories.

To me the question becomes:
Should FreeBSD make a corresponding change? I imagine it would be a fairly trivial patch to adduser (which is a shell script)

I think it should, but changing it violates POLA, but the change of default shell from csh to sh also violated POLA.
For me personally, I don't really care. My FreeBSD systems are single user home directories, Linux work systems again are still single home directory systems, so "sixes and threes"
 
T-Aoki T-Daemon Yep both work, I think I referenced both previously. I think the OP issue is adduser on FreeBSD works differently from Linux in this area.

To me this is interesting exercise:
Linux changed the default value; from a security POV the change makes sense. But it only affects systems with multiple user accounts that actually have home directories.

To me the question becomes:
Should FreeBSD make a corresponding change? I imagine it would be a fairly trivial patch to adduser (which is a shell script)

I think it should, but changing it violates POLA, but the change of default shell from csh to sh also violated POLA.
For me personally, I don't really care. My FreeBSD systems are single user home directories, Linux work systems again are still single home directory systems, so "sixes and threes"
My assumption is, if changing the current default, it should only be done on brand-new point-zero release branch such as upcoming 15.0 to avoid POLA violations.

But I consider, as I repeatedly noting here and there, FreeBSD to be a "base OS". Distros (like GhostBSD) / derivatives (like HardenedBSD) using FreeBSD as its base can freely change the default from FreeBSD.

And "Linux" is precisely "kernel only" and so-called "Linux" are usually distros using Linux kernel. Any distro can have its own policy, if the kernel can support it. So as FreeBSD-based distros, but not limited with kernel only.
 
My assumption is, if changing the current default, it should only be done on brand-new point-zero release branch such as upcoming 15.0 to avoid POLA violations.
I completely agree. Do it on a "dot zero" and be done with it.
Oh, but the new default would only apply to newly added users. Upgrading a system from say 14.3 to 15.0, existing /home/{user} would have old defaults.
I tend to look at this "if the system administrator security policy mandates that user home directories can only be accessed by the owner, the admin needs to manage this via policy/manual intervention"

And "Linux" is precisely "kernel only" and so-called "Linux" are usually distros using Linux kernel. Any distro can have its own policy, if the kernel can support it. So as FreeBSD-based distros, but not limited with kernel only.
Understood; saying "Linux" to mean "distributions based on Linux with additions by Canonical/Ubuntu/RedHat" is like saying "Kleenex" to mean "tissues to blow your nose" or "Xerox machine" to generically mean "copy machine".
I don't know if adduser is part of some package that Linux distributions all include (like gnu binutils, glibc and others) or if it is part of "Linux". I'm guessing some standard package they all include. Interestingly, on "Linux distros" adduser is a Perl script on FreeBSD (likely Net/Open/DragonFlyBSD too) it's a sh script. So rewritten in Perl.
 
Oh, but the new default would only apply to newly added users.
This is not limited with FreeBSD.
IT dept. often sends "Run this script as all existing users on the computer to apply new defaults. Only newly logged in users can have this new defaults by default." for Windows PCs.
 
  • Like
Reactions: mer
This is not limited with FreeBSD.
IT dept. often sends "Run this script as all existing users on the computer to apply new defaults. Only newly logged in users can have this new defaults by default." for Windows PCs.
Exactly. As a former manager used to say "This is not a problem that is unique to $currentworkplace"
 
Currently, the default behavior on a Debian 12 adduser is:
Code:
ls -al /home

total 32

drwxr-xr-x  5 root root  4096 14 juin  21:35 .

drwxr-xr-x 19 root root  4096 17 juin  22:34 ..

drwx------ 15 jo   jo    4096 16 juin  11:54 jo

drwx------  2 root root 16384 14 juin  20:24 lost+found

drwx------ 24 mic  mic   4096 17 juin  21:21 mic
Thing that is not so bad for the system administration The admin will not look any further, the job is made for him Good or bad, everything is point of view. Is it possible or necessary to change the adduser command on FreeBSD? Not sure
 
Currently, the default behavior on a Debian 12 adduser is:
Code:
ls -al /home

total 32

drwxr-xr-x  5 root root  4096 14 juin  21:35 .

drwxr-xr-x 19 root root  4096 17 juin  22:34 ..

drwx------ 15 jo   jo    4096 16 juin  11:54 jo

drwx------  2 root root 16384 14 juin  20:24 lost+found

drwx------ 24 mic  mic   4096 17 juin  21:21 mic
Thing that is not so bad for the system administration The admin will not look any further, the job is made for him Good or bad, everything is point of view. Is it possible or necessary to change the adduser command on FreeBSD? Not sure
Interesting. Not even "group" access. Which given the trend of "every user has their own group" is also a reasonable thing. Thanks for showing.
 
I would vote for NOT changing the defaults on FreeBSD. Yeah, that is in line with POLA. If it ain't broke, don't fix it. Keep It Simple, Stupid.

Want it done right? do it yourself if you have enough knowledge to not mess up.
 
Back
Top