Bug 110288 - usermod -d <new dir> -m <existing user> doesn't work as advertised
usermod -d <new dir> -m <existing user> doesn't work as advertised
Status: CLOSED NOTABUG
Product: Red Hat Linux
Classification: Retired
Component: shadow-utils (Show other bugs)
9
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Nalin Dahyabhai
David Lawrence
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2003-11-17 17:27 EST by Bishop Clark
Modified: 2007-04-18 12:59 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2003-11-20 21:20:47 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
strace of 'moduser -d /home/steve2 -m steve' (10.24 KB, text/plain)
2003-11-17 17:30 EST, Bishop Clark
no flags Details

  None (edit)
Description Bishop Clark 2003-11-17 17:27:39 EST
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (Windows; U; Win98; en-GB; rv:1.5) Gecko/20031007

Description of problem:

The man page (in the messed up default charset - can we get an 'export
LANG=C' put into the profile as a fix, please?) for usermod says:


-d home_dir
     The user�s new login directory.  If the -m option is  given  the
     contents  of the current home directory will be moved to the new
     home directory, which is created if it does not already exist.

I'm reading this as at least "if there's no ~, make one."  Seems
that's not what it's doing:

[root@fishy root]# usermod -d /home/steve -m steve
[root@fishy root]# ls -l ~steve
ls: /home/steve: No such file or directory

in fact, (see attachment, strace) it doesn't even seem to be checking
to see if ~steve's even there!


Version-Release number of selected component (if applicable):
shadow-utils-4.0.3-6

How reproducible:
Always

Steps to Reproduce:
1. usermod -d <new dir> -m <some user>
2. ls -l ~<same user>
3.


Actual Results:  Nothing.  Well, changes to /etc/passwd, of course. 
No files moved, no dirs created.

Expected Results:  I had hoped that ~steve would exist, at the least.
 I mean, I can do me a mv, or a mkdir-p / chown / chmod dance, but I
was hoping that it would just kinda work.

Additional info:

My box is so stock, probably rpm -Va would be clean.
Comment 1 Bishop Clark 2003-11-17 17:30:22 EST
Created attachment 96030 [details]
strace of 'moduser -d /home/steve2 -m steve'

Have a strace.	Watch it prove me wrong.  8-)

(actually it nullifies some of it.  It seems to be checking to see if the old
dir exists .. but it's still not creating the new)
Comment 2 Nalin Dahyabhai 2003-11-20 21:01:10 EST
I'd read it as "whatever was in the old home directory gets moved to
the new location".

If I'm reading the strace output right, the original home directory
was /home/steve, which didn't exist.  usermod searched for the
contents of the home directory, determined that there was nothing to
move, and did nothing, which is what I'd have expected.

Unless I'm missing something here, I'm inclined to mark this notabug.
Comment 3 Bishop Clark 2003-11-20 21:20:47 EST
Sure.  It then boils down to just a badly-worded manpage.  No big deal.
Comment 4 Nalin Dahyabhai 2003-11-20 21:24:56 EST
Okay, good to know we're on the same page.  If you have a clearer
wording, I can ask upstream if they want to incorporate it.  Thanks!
Comment 5 Bishop Clark 2003-11-21 06:54:47 EST
Yeah, that would be cool.  Is it the PLD folks maintaining that
source?  If so, I can mail Tomasz instead, if you're busy (and that's
labour you don't have to do!)

I'm not thinking anything too major; just changing the logic as
described on the manpage to match what's actually happening, and I'm
thinking it just needs a few added words for that:

  if -d specified ; then
+   if [ -d current_home ]; then
      if [ ! -d new_home ] ; then
        install -d -o $(id -un <user>) -g $(id -gn <user>) new_home
      fi
-   if [ -d current_home ]; then
      mv_and_rechown (current_home, new_home)
    fi
  fi

diff -uBb /home/bishop/cvs/shadow/man/usermod.8\~
/home/bishop/cvs/shadow/man/usermod.8
--- /home/bishop/cvs/shadow/man/usermod.8~      2003-10-21
13:13:11.000000000 -0700
+++ /home/bishop/cvs/shadow/man/usermod.8       2003-11-21
03:49:53.000000000 -0800
@@ -48,9 +48,10 @@
 The new value of the user's password file comment field. It is normally
 modified using the \fBchfn\fR(1) utility.
 .IP "\fB-d\fR \fIhome_dir\fR"
-The user's new login directory. If the \fB-m\fR option is given the
contents
-of the current home directory will be moved to the new home
directory, which
-is created if it does not already exist.
+The user's new login directory. If the \fB-m\fR option is given and
+the current home directory exists, the contents of the current home
+directory will be moved to the new home directory, which is created if
+it does not already exist.
 .IP "\fB-e\fR \fIexpire_date\fR"
 The date on which the user account will be disabled. The date is
specified
 in the format \fIYYYY-MM-DD\fR.




Comment 6 Nalin Dahyabhai 2003-11-21 14:53:51 EST
Yes, so far as I know the PLD site (http://shadow.pld.org.pl/) is
still the official upstream.  Thanks!
Comment 7 Bishop Clark 2003-11-24 01:29:58 EST
Sent.  

Maybe it'll appear, maybe not.

Thanks a lot for your help, as always.

 - bish

Note You need to log in before you can comment on or make changes to this bug.