Opened 5 years ago

Last modified 3 years ago

#49501 reopened defect

Spaces and Backslashes in Group Names

Reported by: citibob@… Owned by: macports-tickets@…
Priority: Low Milestone:
Component: base Version: 2.3.4
Keywords: haspatch Cc: ryandesign (Ryan Schmidt), chucko58 (Chuck Fry), neverpanic (Clemens Lang)
Port:

Description

I'm installing MacPorts non-root. Unfortunately, my group name has a space and backslash in it. This cannot be changed at my organization:

> whoami
johndoe
> id -g -n `whoami`
NDC\Domain Users

MacPorts doesn't work when you try to ./configure and then make install. I currently have a workaround; the general idea is to use a numeric group ID instead of group name. First, I configure as follows (Python code here):

user_info = pwd.getpwuid(os.getuid())
self.pw_name = user_info[0] # pw_name
self.pw_gid =  user_info[3] # pw_gid


cmd = ['./configure', '--enable-readline',
     '--prefix={}'.format(self.dest_dir),
     '--with-install-user={}'.format(self.pw_name),
     '--with-install-group={}'.format(self.pw_gid)]

self.run_cmd(cmd, cwd=self.src_dir)

Then I apply the following patches on the generated files before running make:

file_replace(os.path.join(self.src_dir, 'doc/base.mtree'), 'gname', 'gid')
file_replace(os.path.join(self.src_dir, 'doc/prefix.mtree'), 'gname', 'gid')

file_replace(os.path.join(self.src_dir, 'doc/macosx.mtree'),
    'uname=root gname=wheel', 'uname={} gid={}'.format(self.pw_name, self.pw_gid))
file_replace(os.path.join(self.src_dir, 'doc/macosx.mtree'),
    'uname=root gname=admin', 'uname={} gid={}'.format(self.pw_name, self.pw_gid))

Would it be possible to update the core MacPorts so this patching is not required? Also... a similar fix would probably be needed for those poor souls with backslashes or spaces in their username.

Attachments (1)

svn.diffs (3.8 KB) - added by chucko58 (Chuck Fry) 4 years ago.
'svn diff' of a fix against r148086

Download all attachments as: .zip

Change History (11)

comment:1 Changed 5 years ago by ryandesign (Ryan Schmidt)

Cc: ryandesign@… added
Resolution: invalid
Status: newclosed

I've never heard of a space or backslash being a legal character in a username or group name. I did a little research:

The Open Group Base Specification issue 7 has a definition of a user name and a group name that both say:

the value is composed of characters from the portable filename character set

The definition of the portable filename character set says:

The set of characters from which portable filenames are constructed.

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 8 9 . _ -

The backslash and the space are not part of that set of characters, so your group name is illegal on UNIX operating systems such as OS X. Please have your system administrator change your group name to one that is legal.

comment:2 Changed 5 years ago by citibob@…

Resolution: invalid
Status: closedreopened

I'm not going to dispute the logic of the above reply, and I agree 100% that spaces and backslashes in filenames are a BAD IDEA. However, we are stuck with them for all practical purposes. This computer network is at a large, well-known Federal agency --- almost certainly it's a Windows network at its core. The main job of IT is to make sure that people can run MS Office on their MS Desktops, and to deny root access to as many users as possible. Getting the latest GCC and boost running under MacPorts is NOT their job. You can guess how far I got when I submitted a ticket for this problem to them, asking them to fix the group names --- that's right, I didn't even get a reply.

There is often a difference between standard specs and facts on the ground. Spaces and backslashes are de facto legal in Mac group names, regardless of what the Open Group spec says. Asking Apple to make their system Open Group compliant in this regard (by rejecting illegal group names) will likely be as successful as my above efforts with our large Federal Agency IT department.

Therefore, we are stuck with these crazy group names, and MacPorts is the only viable place where the issue can be resolved. There seem to be two ways forward:

  1. Fix the issue, even thought it isn't really the "fault" of MacPorts. There are plenty of cases where software package A has to create a workaround for a bug in software package B.
  1. Decide that non-root MacPorts is not supported on the Macs in our large Federal agency because our systems don't (quite) conform to Open Group standards. This won't stop us from using it, because I've already created a workaround for the problem --- one that I would publish and share with others who also need to run MacPorts. But it would seem better if we could get this issue fixed the "right" way, rather than relying on my hackish post-configure Python script to do the job.

comment:3 Changed 4 years ago by ryandesign (Ryan Schmidt)

Cc: chuck.fry@… added

Has duplicate #51232.

comment:4 Changed 4 years ago by chucko58 (Chuck Fry)

Unfortunately I'm in the same boat as the submitter, thus my duplicate report. This is a problem for those of us at federal agencies.

comment:5 Changed 4 years ago by ryandesign (Ryan Schmidt)

This may actually be a duplicate of #43875 which was fixed already in trunk, but was not backported to the 2.3 branch. So please try building trunk and let us know if it's fixed there or not.

comment:6 Changed 4 years ago by chucko58 (Chuck Fry)

This is broken in trunk as of 4/26/16 13:30 PST, but in a slightly different fashion, in an mtree script.

env PATH=/usr/bin:/bin:/usr/sbin:/sbin CFLAGS="-pipe -Os" ./configure --enable-readline --prefix=/Users/cfry --with-applications-dir=/Users/cfry/Applications --with-no-root-privileges
make install

results in:

* Warning: Using pre-generated man pages only.
* asciidoc, xsltproc (port libxslt) and docbook-xsl are required to generate man pages from source.
/usr/bin/install -c -d -o "cfry" -g "NDC\Domain Users" -m "0755" "/Users/cfry"
/usr/bin/install -c -d -o "cfry" -g "NDC\Domain Users" -m "0755" "/Users/cfry/etc/macports"
< prefix.mtree /usr/sbin/mtree -U -e -p "/Users/cfry" > /dev/null
mtree: line 6: unknown group NDC\Domain
make[1]: *** [install] Error 1
make: *** [install] Error 1
rdnzl:base cfry$

I tried quoting the group name in base/doc/prefix.mtree, with no luck. Single quotes, double quotes, and backslashes in front of special characters all failed in the same way.

Changed 4 years ago by chucko58 (Chuck Fry)

Attachment: svn.diffs added

'svn diff' of a fix against r148086

comment:7 Changed 4 years ago by chucko58 (Chuck Fry)

The attachment svn.diffs is the set of changes I had to make to get 'make install' to work on OS X 10.10.5. I hope you find it useful.

comment:8 Changed 4 years ago by ryandesign (Ryan Schmidt)

Keywords: haspatch added

Thanks!

comment:9 Changed 4 years ago by ryandesign (Ryan Schmidt)

Cc: cal@… added

Clemens, what do you think of this proposed patch?

comment:10 Changed 3 years ago by jmroot (Joshua Root)

We ship several of the modified files in the pkg, and I doubt we can rely on the gid being the same on every target machine.

Last edited 3 years ago by jmroot (Joshua Root) (previous) (diff)
Note: See TracTickets for help on using tickets.