1

I execute the script below as root within MAC OS X terminal. The piped command runs successfully, but the script fails at the chown command with the following error:

chown: Domain Users: illegal group name

Why?

See script below:

#!/bin/bash

echo Enter username
read Name
echo Enter number
read NUM

sudo -s "(cd /Users/$NAME && tar c .) | (cd /Users/$NUM && tar xf -)"
sudo chown -R $NUM:"Domain Users" /Users/$NUM
sudo chmod g+rwx /Users/$NUM
Cyrus
  • 84,225
  • 14
  • 89
  • 153
  • Domain Users sounds like an AD group name. If that is the case the group membership is coming from OpenDirectory on OSX. You won't be able to do a `chown` with an AD group. and either way. "Domain Users" would never be considered a valid unix group. – ptierno Nov 01 '14 at 20:26
  • @Petey T: This Mac is bound to Active Directory so why would its group membership come from OpenDirectory? – Digital Impermanence Nov 01 '14 at 20:28
  • @Petey T: Furthermore, I have ran these three commands manually as root multiple times with 100% success so I fail to see how what your saying is correct. – Digital Impermanence Nov 01 '14 at 20:31
  • @Petey T: "manually as root"...within Terminal that is. I have executed them one-by-one within Terminal numerous times with no problem. – Digital Impermanence Nov 01 '14 at 20:31
  • OpenDirectory is what the mac uses to interact with active directory. Hence why I said 'AD' group. not opendirectory group. – ptierno Nov 01 '14 at 20:33
  • @Petey T: So OpenDirectory is an application running on OS X that helps to integrate OD and AD? – Digital Impermanence Nov 01 '14 at 20:34
  • And if that is not the case then i don't know. Other wise I would have submitted an answer, not a comment. – ptierno Nov 01 '14 at 20:35
  • You have a mix of upper and lower case variable names. I don't know if that is an issue. I would add 'set -x' to the top of the script and see if it is executing what you think it is executing. – Dan Garthwaite Nov 01 '14 at 20:36
  • @Petey T: either way you did not respond to my point: I have run these commands verbatim from terminal using the group "Domain Users" with absolutely no problem. So again, I fail to see how your first comment explains anything. – Digital Impermanence Nov 01 '14 at 20:36
  • @DigitalImpermanence as it turns out my first comment doesn't explain anything. Just ran a test case. And as you stated. works with no issues. Apologies – ptierno Nov 01 '14 at 20:38
  • @Petey T: In my mind "Domain Users" is a group local to this machine. I don't know exactly where it lives, but I'm not under the impression that the chown command I was trying to use is attempting to call out to the domain controllers and take ownership of stuff on the home directory servers or something like that. My impression is that for the most part this chown command is operating locally, on stuff that is local. – Digital Impermanence Nov 01 '14 at 20:39
  • @Petey T: Not a problem at all. And thus my confusion... – Digital Impermanence Nov 01 '14 at 20:40

2 Answers2

3

"Domain Users" is an Active Directory group, hence one must be connected to the domain in order to CHOWN against a specified user within this group and take ownership of the resources specified. I was working remotely this day and was not connected via our VPN, hence not connected to our domain and thus unable to CHOWN against this Active Directory group "Domain Users".

0

Your reading the variables wrong:

should look like this:

...
read NAME
....
read NUM
ptierno
  • 9,534
  • 2
  • 23
  • 35
  • Ehh...that's just how I entered the text on the stack site, my friend. In the actual script they're both formatted in all caps. – Digital Impermanence Nov 01 '14 at 20:42
  • 1
    You should probably edit and give correct syntax in the code block. Just so we can help rule out syntax errors. – ptierno Nov 01 '14 at 20:43
  • fixing it in the question isn't going to help anyone else looking at it. you should visit the 'help' and 'tour'sections of the site. – ptierno Nov 01 '14 at 20:44