Compare commits

...
Sign in to create a new pull request.

1 commit

Author SHA1 Message Date
Alexander Boström
0623f982f2 Create a home directory for the Anyterm user.
Create a known_hosts for localhost.
Fix anyterm-cmd.
2012-06-02 12:22:06 +02:00
2 changed files with 48 additions and 9 deletions

View file

@ -3,14 +3,32 @@
# Simply prompt the user for a username and
# ssh locally as that user
set -eo pipefail
while : ; do
echo -n "Username: "
read U
if [[ -z "$U" ]]; then
echo "Disconnecting."
exit
fi
# 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
ssh "$U@localhost"
if [[ "$U" =~ ^[A-Za-z0-9_][A-Za-z0-9_-]*$ ]]; then
cd ~
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 -l "$U" localhost.localdomain" || :
else
echo "Bad username."
echo "Bad username."
fi
done

View file

@ -1,6 +1,6 @@
Name: anyterm
Version: 1.1.29
Release: 11%{?dist}
Release: 11%{?dist}.1
Summary: A web-based terminal emulator
Group: Applications/Internet
@ -74,17 +74,31 @@ 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} -p -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 [[ ! -d %{_localstatedir}/run/%{name} ]]; then
mkdir -m755 %{_localstatedir}/run/%{name}
chown %{name}:%{name} %{_localstatedir}/run/%{name}
fi
if [[ $(getent passwd %{name} | cut -d: -f6) == /dev/null ]]; then
usermod -d %{_localstatedir}/run/%{name} %{name}
fi
exit 0
%post
@ -105,6 +119,8 @@ fi
%{_initrddir}/anyterm
%{_datadir}/anyterm/
%config(noreplace) %{_sysconfdir}/sysconfig/anyterm
%ghost %attr(0755,%{name},%{name}) %dir %{_localstatedir}/run/%{name}
%{_sysconfdir}/tmpfiles.d/%{name}.conf
%doc LICENSE
%files httpd
@ -112,6 +128,11 @@ fi
%config(noreplace) %{_sysconfdir}/httpd/conf.d/anyterm.conf
%changelog
* Sat Jun 2 2012 Alexander Boström <abo@root.snowtree.se> - 1.1.29-11.1
- Create a home directory for the Anyterm user.
- Create a known_hosts for localhost.
- Fix anyterm-cmd.
* Tue Feb 28 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.1.29-11
- Rebuilt for c++ ABI breakage