Hi tech@,

I stumbled on SUPPORT_DOT while reading /usr/src/bin/chmod.c, got curious
and started doing some research.

POSIX changed the separator from . to : to make the utility properly work with
usernames containing a dot. The standard doesn't forbid keeping the dot handling
for backwards compatiblity.

The code is currently #ifdef'ed in. I assume the reason was to phase it out
sometime in the future.

The code was there and enabled with CFLAGS back in 1995
https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.sbin/chown/Attic/Makefile?rev=1.1&content-type=text/x-cvsweb-markup

There were some attempts to weed it out but as far as I see they were abandonned
or stopped.

Back in 2001, by disabling the compat and trying to build the base system, no
followup email (that I can find): 
https://marc.info/?l=openbsd-tech&m=99647882113533&w=2

Discussion that brought SUPPORT_DOT into the topic. Mostly people argumenting if
man pages shold be altered (sorry, can't find the thread on marc.info):

http://misc.openbsd.narkive.com/4ejjhI6O/in-username

I think it's unlikely at this point that this backwards support will go away.
Linux, Mac, NetBSD and FreeBSD all support the compat, people seem to be using a
mix of both (including in our base where ie. /etc/netstart uses the dot
notation).

I suggest dropping the ifdef and define. It's been built enabled by default for
22 years. I'm also adding a diff for /etc/netstart to switch it to the :
separator. It's one less strchr call, though that obviously doesn't make
much difference performance wise in this case.

Feedback? OK's?
? chmod
? support_dot.diff
Index: Makefile
===================================================================
RCS file: /cvs/src/bin/chmod/Makefile,v
retrieving revision 1.8
diff -u -p -r1.8 Makefile
--- Makefile    11 Sep 2016 07:06:29 -0000      1.8
+++ Makefile    27 May 2017 18:39:17 -0000
@@ -1,7 +1,6 @@
 #      $OpenBSD: Makefile,v 1.8 2016/09/11 07:06:29 natano Exp $
 
 PROG=  chmod
-CFLAGS+=-DSUPPORT_DOT
 MAN=   chmod.1 chgrp.1 chown.8 chflags.1
 LINKS= ${BINDIR}/chmod ${BINDIR}/chgrp \
        ${BINDIR}/chmod /sbin/chown
Index: chmod.c
===================================================================
RCS file: /cvs/src/bin/chmod/chmod.c,v
retrieving revision 1.41
diff -u -p -r1.41 chmod.c
--- chmod.c     17 Feb 2017 10:14:12 -0000      1.41
+++ chmod.c     27 May 2017 18:39:17 -0000
@@ -197,14 +197,12 @@ done:
                        *cp++ = '\0';
                        gid = a_gid(cp);
                }
-#ifdef SUPPORT_DOT
                /* UID and GID are separated by a dot and UID exists. */
                else if ((cp = strchr(*argv, '.')) != NULL &&
                    (uid = a_uid(*argv, 1)) == (uid_t)-1) {
                        *cp++ = '\0';
                        gid = a_gid(cp);
                }
-#endif
                if (uid == (uid_t)-1)
                        uid = a_uid(*argv, 0);
        } else
? netstart.diff
Index: netstart
===================================================================
RCS file: /cvs/src/etc/netstart,v
retrieving revision 1.183
diff -u -p -r1.183 netstart
--- netstart    7 May 2017 09:40:15 -0000       1.183
+++ netstart    27 May 2017 18:47:51 -0000
@@ -99,7 +99,7 @@ ifstart() {
        if [[ "${_stat[0]}${_stat[2]}${_stat[3]}" != *---00 ]]; then
                echo "WARNING: $_file is insecure, fixing permissions"
                chmod -LR o-rwx $_file
-               chown -LR root.wheel $_file
+               chown -LR root:wheel $_file
        fi
 
        # Check for ifconfig'able interface, except if -n option is specified.

Reply via email to