commit - be7ce7ce020aa928cb681a0c23ac4ae7a350a42b
commit + 2668ec1c3f803454fa75fdcfd86d3a8e6d9ab069
blob - 8c2238b281ee524d944079247a1c70606b88362f
blob + c7dbe6c154af86c95cb78fd351ade423c0e54aef
--- gotsysd/libexec/gotsys-useradd/gotsys-useradd.c
+++ gotsysd/libexec/gotsys-useradd/gotsys-useradd.c
if (user != NULL)
continue; /* will go on existing_users list */
- err = gotsys_conf_validate_name(pw->pw_name, "user");
- if (err)
- goto done;
+ if (strcmp(pw->pw_name, "anonymous") != 0) {
+ err = gotsys_conf_validate_name(pw->pw_name, "user");
+ if (err) {
+ goto done;
+ }
+ }
err = gotsys_conf_new_user(&user, pw->pw_name);
if (err)
blob - cee6986bf6095cfe5d4b8356cda3408ed7b8f7f5
blob + d8a6a0669ccae57aaf4c5fa85f67acd017b0f6be
--- regress/gotsysd/test_gotsysd.sh
+++ regress/gotsysd/test_gotsysd.sh
ret=$?
if [ $ret -ne 0 ]; then
echo "got clone failed unexpectedly" >&2
+ test_done "$testroot" 1
+ return 1
+ fi
+
+ test_done "$testroot" "$ret"
+}
+
+test_user_anonymous_remove() {
+ local testroot=`test_init user_anonymous_remove 1`
+
+ got checkout -q $testroot/${GOTSYS_REPO} $testroot/wt >/dev/null
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ echo "got checkout failed unexpectedly" >&2
+ test_done "$testroot" 1
+ return 1
+ fi
+
+ crypted_vm_pw=`echo ${GOTSYSD_VM_PASSWORD} | encrypt | tr -d '\n'`
+ crypted_pw=`echo ${GOTSYSD_DEV_PASSWORD} | encrypt | tr -d '\n'`
+ sshkey=`cat ${GOTSYSD_SSH_PUBKEY}`
+ cat > ${testroot}/wt/gotsys.conf <<EOF
+group slackers
+
+user ${GOTSYSD_TEST_USER} {
+ password "${crypted_vm_pw}"
+ authorized key ${sshkey}
+}
+user ${GOTSYSD_DEV_USER} {
+ password "${crypted_pw}"
+ authorized key ${sshkey}
+}
+repository gotsys.git {
+ permit rw ${GOTSYSD_TEST_USER}
+ permit rw ${GOTSYSD_DEV_USER}
+}
+repository "foo" {
+ permit rw ${GOTSYSD_DEV_USER}
+}
+EOF
+ (cd ${testroot}/wt && got commit -m "remove anonymous user" >/dev/null)
+ local commit_id=`git_show_head $testroot/${GOTSYS_REPO}`
+
+ got send -q -i ${GOTSYSD_SSH_KEY} -r ${testroot}/${GOTSYS_REPO}
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ echo "got send failed unexpectedly" >&2
+ test_done "$testroot" 1
+ return 1
+ fi
+
+ # Wait for gotsysd to apply the new configuration.
+ echo "$commit_id" > $testroot/stdout.expected
+ for i in 1 2 3 4 5; do
+ sleep 1
+ ssh -i ${GOTSYSD_SSH_KEY} root@${VMIP} \
+ cat /var/db/gotsysd/commit > $testroot/stdout
+ if cmp -s $testroot/stdout.expected $testroot/stdout; then
+ break;
+ fi
+ done
+ cmp -s $testroot/stdout.expected $testroot/stdout
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ echo "gotsysd failed to apply configuration" >&2
+ diff -u $testroot/stdout.expected $testroot/stdout
+ test_done "$testroot" "$ret"
+ return 1
+ fi
+
+ # Repository foo should no longer be readable anonymously.
+ env SSH_ASKPASS="/usr/bin/true" SSH_ASKPASS_REQUIRE=force \
+ got clone anonymous@${VMIP}:foo.git \
+ $testroot/foo-anonclone.git > /dev/null 2> $testroot/stderr
+ ret=$?
+ if [ $ret -eq 0 ]; then
+ echo "got clone succeeded unexpectedly" >&2
test_done "$testroot" 1
return 1
fi
+ printf "Permission denied, please try again.\r\n" \
+ > $testroot/stderr.expected
+ printf "Permission denied, please try again.\r\n" \
+ >> $testroot/stderr.expected
+ printf "anonymous@${VMIP}: Permission denied (publickey,password,keyboard-interactive).\r\n" \
+ >> $testroot/stderr.expected
+ echo "got-fetch-pack: unexpected end of file" \
+ >> $testroot/stderr.expected
+ echo "got: unexpected end of file" >> $testroot/stderr.expected
+
+ cmp -s $testroot/stderr.expected $testroot/stderr
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ diff -u $testroot/stderr.expected $testroot/stderr
+ test_done "$testroot" "$ret"
+ return 1
+ fi
+
test_done "$testroot" "$ret"
}
run_test test_group_del
run_test test_repo_create
run_test test_user_anonymous
+run_test test_user_anonymous_remove
run_test test_bad_gotsysconf
run_test test_bad_ref_in_gotsysconf
run_test test_set_head