In a MacOS Mojave bash script “-w /etc/passwd” is false even for root

An old bash script I have tested to see if a user was root by seeing if /etc/passwd was writeable. In MacOS High Sierra it returned true for root, and false for anyone else. But in MacOS Mojave the test returns false even for root. If I run that test [ -w File ] on other files with the same permissions and ownership, such as /etc/hosts , it correctly returns true for root and false for anyone else in both Mojave and High Sierra. I see no special file flags or extended attributes on /etc/passwd . The script is no problem to fix, but I’d like to know how/why this test is different on that file vs other files and why this is in Mojave only.

Dovecot can’t read other userdb than /etc/passwd

I had the last day alot of trouble with the dovecot userdb. The problem was that dovecot only read the /etc/passwd and not my custom /etc/dovecot/users file. I changed the /etc/dovecot/auth-passwdfile.conf.ext so that it looked like this (vmail is a user i created on my debian machine):

# Authentication for passwd-file users. Included from 10-auth.conf. # passwd-like file with specified location. # <doc/wiki/AuthDatabase.PasswdFile.txt>  passdb {   driver = passwd-file   args = /etc/dovecot/users }   userdb {   driver = static   args = uid=vmail gid=vmail home=/home/vmail/%u } 

My users file looked like this (sysntax of the /etc/passwd file):

test:{PLAIN}pass:::::: bill:{PLAIN}secret:::::: 

But when I checked if dovecot could read my users file (comand: doveadm user USERNAME) it failed reading the users file.

After I checked if everything was spelled correctly I started searching for the error.

And I found it 🙂

Since the dovecot.conf is just a file including other config files is started to search in those for the error. Somehow dovecot was still searching in /etc/passwd for the users and not in my /etc/dovecot/users file, eventhough I changed the auth-passwdfile.conf.ext. The was in the 10-auth.conf file. This file has several options to include conf files. As default it includes the auth-system.conf.ext file. But this file defines still that /etc/passwd is used as our userdb. So I commented this line and decommented the line including our auth-passwd.conf.ext file. And just to be save I also changed the path in the auth-system.conf.ext file to our /etc/dovecot/users userdb file.

And that’s It. Afters this it worked. The doveadm user test comand is working.

As I am relativly new to this kind of stuff I would be interested in feedback for this solution. And please excuse my bad English.