"User foo already exists" check is broken in installer

Bug #257465 reported by Adam Sampson
2
Affects Status Importance Assigned to Milestone
Nexenta Operating System
Fix Committed
Medium
anilg

Bug Description

(This is for the package nexenta-builder, but launchpad doesn't seem to know about it yet.)

I've just installed the unstable version of Nexenta, and was a bit surprised to be told by the installer that "User ats already exists." when creating a user account.

"ats" didn't already exist, but "gnats" did -- which made me suspicious that it was checking for a substring rather than a match. My suspicions were confirmed by a quick look at the installer source (once I figured out where to get it from):

if cat /etc/passwd|awk -F: '{print $1}'|grep "$user" >/dev/null; then
  oneline_msgbox Error "User $user already exists."
  continue
fi

I'd suggest doing something like this instead, so it checks for an exact match:

if grep "^$user:" /etc/passwd >/dev/null; then
  ...
fi

(You should also use grep -q rather than grep >/dev/null, since you have GNU grep.)

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Related blueprints

Remote bug watches

Bug watches keep track of this bug in other bug trackers.