pg_createcluster crashes when a username or group is specified that contains digits
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
postgresql-common (Ubuntu) |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
pg_createcluster accepts options --user and --group to specify under which credentials a new database cluster should be created. According to the manual page, one may specify either a name or a UID/GID (as digits).
The implementation, however, tests whether there is a digit in the given string, not whether the entire string consists of digits. This causes problems for me: I have a development system where each developer creates databases and such per ticket. Users and groups are created for this purpose, named "ticketNNN" where NNN is the number of the ticket that the developer has been given to implement or bug fix. But pg_createcluster does not like these user and group names, for example "ticket123": it thinks I specified a UID/GID instead of a name, and does the wrong thing. It crashes later on when tries to use the string as a number. This is what it says on my Precise system specifically:
Argument "ticket123" isn't numeric in getpwuid at /usr/share/
Argument "ticket123" isn't numeric in scalar assignment at /usr/share/
Argument "ticket123" isn't numeric in numeric ne (!=) at /usr/share/
This is because the test on line 237 of pg_createcluster:
$owneruid = (getpwnam $owneruid)[2] unless $owneruid =~ /\d+/;
is testing the wrong thing. I think it should read:
$owneruid = (getpwnam $owneruid)[2] unless $owneruid =~ /^\d+$/;
The same happens a few lines down with the group name.
My Ubuntu version information:
Description: Ubuntu 12.04.4 LTS
Release: 12.04
I'm using postgresql-common version 129ubuntu1.
The attachment "Patch for user names and group names containing digits" seems to be a patch. If it isn't, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are a member of the ~ubuntu-reviewers, unsubscribe the team.
[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issues please contact him.]