Bug 110288 - usermod -d <new dir> -m <existing user> doesn't work as advertised
Summary: usermod -d <new dir> -m <existing user> doesn't work as advertised
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: shadow-utils
Version: 9
Hardware: i386
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Nalin Dahyabhai
QA Contact: David Lawrence
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2003-11-17 22:27 UTC by Bishop Clark
Modified: 2007-04-18 16:59 UTC (History)
0 users

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2003-11-21 02:20:47 UTC
Embargoed:


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

Description Bishop Clark 2003-11-17 22:27:39 UTC
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 22:30:22 UTC
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-21 02:01:10 UTC
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-21 02:20:47 UTC
Sure.  It then boils down to just a badly-worded manpage.  No big deal.

Comment 4 Nalin Dahyabhai 2003-11-21 02:24:56 UTC
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 11:54:47 UTC
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 19:53:51 UTC
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 06:29:58 UTC
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.