Forums
New posts
Articles
Product Reviews
Policies
FAQ
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Menu
Log in
Register
Install the app
Install
Forums
macOS & iOS Developer Playground
macOS - Development and Darwin
Change ownership of home directory
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="emmayche" data-source="post: 1785016" data-attributes="member: 398147"><p>In a shell script (running as a launch daemon, thus as root), I'm trying to transfer ownership of a home directory from a local user to a network user.</p><p></p><p>Stripped of all the logging and debugging code, here's what the script does:</p><p></p><p>----</p><p># $sourcedir contains the old directory name (from the old, local user)</p><p># $userdir contains the new directory name (from the new, network, user)</p><p># $tgtgu contains the user:group specifier for the network user (like 3953253:20)</p><p></p><p># Remove any conflicting old directory</p><p>rm -R $userdir || true</p><p></p><p># Rename the old directory to the new name</p><p>mv -f "$sourcedir" "$userdir"</p><p></p><p># Change the ownership</p><p>chown -R $tgtgu \"$userdir\"</p><p>----</p><p></p><p>The 'chown' statement claims that '$userdir' does not exist at that point. Part of the debugging code confirms that the directory does, in fact, exist.</p><p></p><p>Does anyone know why I would not be able to change the owner of the newly-renamed directory, or why chown would report that it does not exist?</p></blockquote><p></p>
[QUOTE="emmayche, post: 1785016, member: 398147"] In a shell script (running as a launch daemon, thus as root), I'm trying to transfer ownership of a home directory from a local user to a network user. Stripped of all the logging and debugging code, here's what the script does: ---- # $sourcedir contains the old directory name (from the old, local user) # $userdir contains the new directory name (from the new, network, user) # $tgtgu contains the user:group specifier for the network user (like 3953253:20) # Remove any conflicting old directory rm -R $userdir || true # Rename the old directory to the new name mv -f "$sourcedir" "$userdir" # Change the ownership chown -R $tgtgu \"$userdir\" ---- The 'chown' statement claims that '$userdir' does not exist at that point. Part of the debugging code confirms that the directory does, in fact, exist. Does anyone know why I would not be able to change the owner of the newly-renamed directory, or why chown would report that it does not exist? [/QUOTE]
Verification
Post reply
Forums
macOS & iOS Developer Playground
macOS - Development and Darwin
Change ownership of home directory
Top