Date: Tue, 28 Jul 2015 12:20:58 +0000 (UTC) From: Baptiste Daroussin <bapt@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r285948 - in head/usr.sbin/pw: . tests Message-ID: <201507281220.t6SCKwwv090325@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: bapt Date: Tue Jul 28 12:20:57 2015 New Revision: 285948 URL: https://svnweb.freebsd.org/changeset/base/285948 Log: when -n is passed to any pw subcommand it is always expected to be considered as a name so do not try to convert it to an id if it is a numeric value PR: 31933 Reported by: ted@impulse.net Sponsored by: gandi.net Modified: head/usr.sbin/pw/pw.c head/usr.sbin/pw/tests/pw_userdel.sh Modified: head/usr.sbin/pw/pw.c ============================================================================== --- head/usr.sbin/pw/pw.c Tue Jul 28 11:21:33 2015 (r285947) +++ head/usr.sbin/pw/pw.c Tue Jul 28 12:20:57 2015 (r285948) @@ -287,14 +287,7 @@ main(int argc, char *argv[]) errstr); break; case 'n': - if (strspn(optarg, "0123456789") != strlen(optarg)) { - name = optarg; - break; - } - id = strtonum(optarg, 0, LONG_MAX, &errstr); - if (errstr != NULL) - errx(EX_USAGE, "Bad id '%s': %s", optarg, - errstr); + name = optarg; break; case 'H': if (conf.fd != -1) Modified: head/usr.sbin/pw/tests/pw_userdel.sh ============================================================================== --- head/usr.sbin/pw/tests/pw_userdel.sh Tue Jul 28 11:21:33 2015 (r285947) +++ head/usr.sbin/pw/tests/pw_userdel.sh Tue Jul 28 12:20:57 2015 (r285948) @@ -50,8 +50,18 @@ delete_files_body() { fi } +atf_test_case delete_numeric_name +delete_numeric_name_body() { + populate_etc_skel + + atf_check ${PW} useradd -n foo -u 4001 + atf_check -e inline:"pw: no such user \`4001'\n" -s exit:67 \ + ${PW} userdel -n 4001 +} + atf_init_test_cases() { atf_add_test_case rmuser_seperate_group atf_add_test_case user_do_not_try_to_delete_root_if_user_unknown atf_add_test_case delete_files + atf_add_test_case delete_numeric_name }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201507281220.t6SCKwwv090325>