# HG changeset patch # User Christophe Lincoln # Date 1307878286 -7200 # Node ID c7205f3db6499fe7ebc720112a9489c4a748d3a2 # Parent 95b88686a28384e95b09c03efc5b76b66079e9a8 Samlls improvment to server tool Shell diff -r 95b88686a283 -r c7205f3db649 Makefile --- a/Makefile Sun Jun 12 12:02:48 2011 +0100 +++ b/Makefile Sun Jun 12 13:31:26 2011 +0200 @@ -15,7 +15,7 @@ $(DESTDIR)$(DOCDIR)/$(PACKAGE) \ $(DESTDIR)$(PREFIX)/bin \ $(DESTDIR)$(PREFIX)/sbin \ - $(DESTDIR)/var/cache/$(PACKAGE) \ + $(DESTDIR)/var/lib/$(PACKAGE) \ $(DESTDIR)$(PREFIX)/share/applications install -m 0755 $(PACKAGE)-sh $(DESTDIR)/bin install -m 0755 $(PACKAGE) $(DESTDIR)$(PREFIX)/bin @@ -25,3 +25,4 @@ install -m 0644 data/$(PACKAGE)-server.conf $(DESTDIR)/etc/$(PACKAGE) install -m 0644 data/$(PACKAGE).desktop \ $(DESTDIR)$(PREFIX)/share/applications + touch $(DESTDIR)/var/lib/$(PACKAGE)/vdisk.files diff -r 95b88686a283 -r c7205f3db649 ssfs-server --- a/ssfs-server Sun Jun 12 12:02:48 2011 +0100 +++ b/ssfs-server Sun Jun 12 13:31:26 2011 +0200 @@ -7,9 +7,10 @@ # app=$(basename $0) -cache=/var/cache/ssfs [ -f "/etc/ssfs/$app.conf" ] && . /etc/ssfs/$app.conf [ -f "./data/$app.conf" ] && . ./data/$app.conf +state=/var/lib/ssfs +share=/usr/share/ssfs # Be sure we're root. [ $(id -u) != 0 ] && gettext "You must be root to run:" && \ @@ -210,15 +211,25 @@ gettext -e "\nBack to the host system:" echo -e " $(hostname)\n" ;; gen-vdisk) +<<<<<<< local + # Generated a virtual disk with a minimal chroot for Ssfs users home. + rootfs=$share/rootfs +======= # Generate a virtual disk with a minimal chroot for Ssfs users home. +>>>>>>> other if [ -d "$root/bin" ]; then - gettext -e "A chroot already exists in:"; echo " $root" + gettext "A chroot already exists in:"; echo " $root" + exit 0 + fi + if [ ! -f "$rootfs/etc/busybox.conf" ]; then + gettext "Missing package ssfs-busybox"; echo exit 0 fi echo "" - gettext "Creating chroot in:"; echo " $root" + gettext "Creating Sshs vdisk minimal chroot"; echo separator - + echo "Chroot path: $root" + # Create vdisk if missing. if [ ! -f "$vdisk" ]; then gettext "Creating virtual disk:"; echo " $vdisk ${size}Gb" @@ -233,22 +244,35 @@ # Create a radically minimal chroot with all libs in /lib. gettext "Creating base files..." mkdir -p $root && cd $root - for d in etc tmp lib usr home root + for d in etc lib home root do mkdir -p $d done && status - cp -a /etc/slitaz-release $root/etc - echo "root:x:0:0:root:/root:/bin/sh" > etc/passwd - echo "root::13525:0:99999:7:::" > etc/shadow - echo "root:x:0:" > etc/group - echo "root:*::" > etc/gshadow + + # /etc files. + cp -f /etc/slitaz-release $root/etc + if [ ! -f "$root/etc/passwd" ]; then + echo "root:x:0:0:root:/root:/bin/sh" > $root/etc/passwd + echo "root::13525:0:99999:7:::" > $root/etc/shadow + echo "root:x:0:" > $root/etc/group + echo "root:*::" > $root/etc/gshadow + fi + + # /dev nodes. #mknod -m 666 $root/dev/null c 1 3 - - gettext "Setting files permissions..." - chmod 640 etc/shadow etc/gshadow - chmod 0700 root && chmod 1777 tmp + + # Ssfs Busybox package install files in $cache and allow easy vdisk + # upgrade folowing SliTaz repo. + gettext "Installing Ssfs Busybox..." + cp -a $rootfs/* $root status +<<<<<<< local + gettext "Setting files permissions..." + chmod 0640 $root/etc/*shadow + chmod 0700 $root/root && status + chmod 4755 $root/bin/busybox +======= # Busybox without deps (get && extract). No system comands are allowed # in /etc/busybox.conf to restrict SSH'd users. gettext "Installing Busybox..." @@ -265,8 +289,8 @@ > $root/etc/busybox.conf echo -e "\n[SUID]" >> $root/etc/busybox.conf echo -e "su = --- root.root" >> $root/etc/busybox.conf +>>>>>>> other chmod 0600 $root/etc/busybox.conf - status # Glib minimal libs, use host lib since package should be installed # from same repo. @@ -274,12 +298,19 @@ for l in ld-*.*so* libc-*.*so libc.so.* libnss_files* do cp -a /lib/$l* $root/lib - done && chmod 0644 $root/lib/* && status + done && status # Ssfs chroot SHell gettext "Installing Ssfs SHell..." install -m 0755 /bin/ssfs-sh $root/bin status + + # List of all system files. + cd $root + for d in bin etc lib sbin + do + find ./$d | sed s'/^.//' + done size=$(du -sh $root | awk '{print $1}') separator @@ -303,19 +334,19 @@ separator && echo "" ;; clean-vdisk) # clean up the vdisk storage chroot. - if [ ! -d "$root/bin" ] || [ ! -d "$root/usr" ]; then + if [ ! -d "$root/bin" ] || [ ! -d "$root/lib" ]; then gettext -e "No chroot found in:"; echo " $root" exit 0 fi gettext -e "\nCleaning virtual disk\n" separator - gettext "Changing directory to:"; echo " $root" + echo "Chroot path: $root" cd $root for dir in * do size=$(du -sh $dir | awk '{print $1}') case "$dir" in - home|root|lost*) + etc|home|root|lost*) gettext "Skipping:"; echo " $dir $size *" ;; *) gettext "Removing:"; echo " $dir $size" diff -r 95b88686a283 -r c7205f3db649 ssfs-sh --- a/ssfs-sh Sun Jun 12 12:02:48 2011 +0100 +++ b/ssfs-sh Sun Jun 12 13:31:26 2011 +0200 @@ -19,7 +19,7 @@ HOME=/home/$USER SYNC=$HOME/Sync SHELL=/bin/sh - PS1='\u@ssfs:\e[1;33m\w\e[0m\$ ' + PS1="$USER@ssfs:\w$ " export HOME SYNC SHELL PS1 cd $HOME && exec /bin/sh $@ fi diff -r 95b88686a283 -r c7205f3db649 web/ssfs.cgi --- a/web/ssfs.cgi Sun Jun 12 12:02:48 2011 +0100 +++ b/web/ssfs.cgi Sun Jun 12 13:31:26 2011 +0200 @@ -5,7 +5,7 @@ . /etc/ssfs/ssfs-server.conf -notes=/var/cache/ssfs/notes +notes=/var/lib/ssfs/notes root=$SSFS_CHROOT vdisk=$(basename $SSFS_VDISK) vsize=$(du -sh $SSFS_VDISK | awk '{print $1}')