[anyterm] Fix spec file typo. Create a home directory for the Anyterm user.

abo abo at fedoraproject.org
Fri Jun 1 22:19:19 UTC 2012


commit 6f0026aec170466bb92ecb600e598af141e19265
Author: Alexander Boström <abo at root.snowtree.se>
Date:   Fri Jun 1 22:54:53 2012 +0200

    Fix spec file typo. Create a home directory for the Anyterm user.

 anyterm-cmd  |   10 ++++++++++
 anyterm.spec |   22 +++++++++++++++++-----
 2 files changed, 27 insertions(+), 5 deletions(-)
---
diff --git a/anyterm-cmd b/anyterm-cmd
index aa9df57..14c0f20 100644
--- a/anyterm-cmd
+++ b/anyterm-cmd
@@ -15,6 +15,16 @@ while : ; do
     # Make sure it does not start with a "-" and only contains valid
     # username characters.
     if [[ "$U" =~ ^[A-Za-z0-9_][A-Za-z0-9_-]*$ ]]; then
+	if [[ ! -e ~/.ssh/known_hosts ]]; then
+	    mkdir -p --mode=700 ~/.ssh
+	    for k in /etc/ssh/ssh_host_{rsa,dsa}_key.pub; do
+		if [[ -r "$k" ]]; then
+		    echo -n "localhost.localdomain "
+		    cat "$k"
+		fi
+	    done >.ssh/known_hosts
+	fi
+
 	ssh "$U at localhost.localdomain" || :
     else
 	echo "Bad username."
diff --git a/anyterm.spec b/anyterm.spec
index aa96ead..81e0e2f 100644
--- a/anyterm.spec
+++ b/anyterm.spec
@@ -74,17 +74,27 @@ for f in browser/*.{html,css,js,png,gif}; do
    %{__install} -m644 "$f" %{buildroot}%{_datadir}/anyterm/
 done
 
+# Create a home directory for the user.
+%{__mkdir} -m755 %{buildroot}%{_localstatedir}/run/%{name}
+mkdir -p %{buildroot}%{_sysconfdir}/tmpfiles.d
+cat <<EOF > %{buildroot}%{_sysconfdir}/tmpfiles.d/%{name}.conf
+d %{_localstatedir}/run/%{name} 0755 root %{name}
+EOF
+
 
 %clean
 rm -rf %{buildroot}
 
 %pre
 # create anyterm group / user
-getent group anyterm >/dev/null || \
-   /usr/sbin/groupadd -r anyterm
-getent passwd anyterm > /dev/null || \
-  /usr/sbin/useradd  -r -s /sbin/nologin -d /dev/null \
-  -M -c 'Anyterm user' -g anyterm anyterm
+getent group %{name} >/dev/null 2>&1 || \
+   groupadd -r %{name}
+getent passwd %{name} >/dev/null 2>&1 || \
+  useradd -r -l -g %{name} -s /sbin/nologin \
+  -d %{_localstatedir}/run/%{name} -c "Anyterm service" %{name}
+if [[ $(getent passwd anyterm|cut -d: -f6) == "/dev/null" ]]; then
+  usermod -d %{_localstatedir}/run/%{name} %{name}
+fi
 exit 0
 
 %post
@@ -119,6 +129,7 @@ fi
 %{_mandir}/man1/anytermd.1.gz
 %{_datadir}/anyterm/
 %{_unitdir}/anyterm.service
+%ghost %attr(0755,%{name},%{name}) %dir %{_localstatedir}/run/%{name}
 %doc LICENSE
 
 %files httpd
@@ -128,6 +139,7 @@ fi
 %changelog
 * Fri Jun  1 2012 Alexander Boström <abo at root.snowtree.se> - 1.1.29-13
 - Fix spec file typo.
+- Create a home directory for the Anyterm user.
 
 * Tue May 22 2012 Alexander Boström <abo at root.snowtree.se> - 1.1.29-12
 - Remove SysV script, add systemd service file.


More information about the scm-commits mailing list