ssfs rev 34

Samlls improvment to server tool Shell
author Christophe Lincoln <pankso@slitaz.org>
date Sun Jun 12 13:31:26 2011 +0200 (2011-06-12)
parents 95b88686a283
children 72c49d4cc4e9
files Makefile ssfs-server ssfs-sh web/ssfs.cgi
line diff
     1.1 --- a/Makefile	Sun Jun 12 12:02:48 2011 +0100
     1.2 +++ b/Makefile	Sun Jun 12 13:31:26 2011 +0200
     1.3 @@ -15,7 +15,7 @@
     1.4  		$(DESTDIR)$(DOCDIR)/$(PACKAGE) \
     1.5  		$(DESTDIR)$(PREFIX)/bin \
     1.6  		$(DESTDIR)$(PREFIX)/sbin \
     1.7 -		$(DESTDIR)/var/cache/$(PACKAGE) \
     1.8 +		$(DESTDIR)/var/lib/$(PACKAGE) \
     1.9  		$(DESTDIR)$(PREFIX)/share/applications
    1.10  	install -m 0755 $(PACKAGE)-sh $(DESTDIR)/bin
    1.11  	install -m 0755 $(PACKAGE) $(DESTDIR)$(PREFIX)/bin
    1.12 @@ -25,3 +25,4 @@
    1.13  	install -m 0644 data/$(PACKAGE)-server.conf $(DESTDIR)/etc/$(PACKAGE)
    1.14  	install -m 0644 data/$(PACKAGE).desktop \
    1.15  		$(DESTDIR)$(PREFIX)/share/applications
    1.16 +	touch $(DESTDIR)/var/lib/$(PACKAGE)/vdisk.files
     2.1 --- a/ssfs-server	Sun Jun 12 12:02:48 2011 +0100
     2.2 +++ b/ssfs-server	Sun Jun 12 13:31:26 2011 +0200
     2.3 @@ -7,9 +7,10 @@
     2.4  #
     2.5  
     2.6  app=$(basename $0)
     2.7 -cache=/var/cache/ssfs
     2.8  [ -f "/etc/ssfs/$app.conf" ] && . /etc/ssfs/$app.conf
     2.9  [ -f "./data/$app.conf" ] && . ./data/$app.conf
    2.10 +state=/var/lib/ssfs
    2.11 +share=/usr/share/ssfs
    2.12  
    2.13  # Be sure we're root.
    2.14  [ $(id -u) != 0 ] && gettext "You must be root to run:" && \
    2.15 @@ -210,15 +211,25 @@
    2.16  		gettext -e "\nBack to the host system:"
    2.17  		echo -e " $(hostname)\n" ;;
    2.18  	gen-vdisk)
    2.19 +<<<<<<< local
    2.20 +		# Generated a virtual disk with a minimal chroot for Ssfs users home.
    2.21 +		rootfs=$share/rootfs
    2.22 +=======
    2.23  		# Generate a virtual disk with a minimal chroot for Ssfs users home.
    2.24 +>>>>>>> other
    2.25  		if [ -d "$root/bin" ]; then
    2.26 -			gettext -e "A chroot already exists in:"; echo " $root"
    2.27 +			gettext "A chroot already exists in:"; echo " $root"
    2.28 +			exit 0
    2.29 +		fi
    2.30 +		if [ ! -f "$rootfs/etc/busybox.conf" ]; then
    2.31 +			gettext "Missing package ssfs-busybox"; echo
    2.32  			exit 0
    2.33  		fi
    2.34  		echo ""
    2.35 -		gettext "Creating chroot in:"; echo " $root"
    2.36 +		gettext "Creating Sshs vdisk minimal chroot"; echo
    2.37  		separator
    2.38 -
    2.39 +		echo "Chroot path: $root"
    2.40 +		
    2.41  		# Create vdisk if missing.
    2.42  		if [ ! -f "$vdisk" ]; then
    2.43  			gettext "Creating virtual disk:"; echo " $vdisk ${size}Gb"
    2.44 @@ -233,22 +244,35 @@
    2.45  		# Create a radically minimal chroot with all libs in /lib.
    2.46  		gettext "Creating base files..."
    2.47  		mkdir -p $root && cd $root
    2.48 -		for d in etc tmp lib usr home root
    2.49 +		for d in etc lib home root
    2.50  		do
    2.51  			mkdir -p $d
    2.52  		done && status
    2.53 -		cp -a /etc/slitaz-release $root/etc
    2.54 -		echo "root:x:0:0:root:/root:/bin/sh" > etc/passwd
    2.55 -		echo "root::13525:0:99999:7:::" > etc/shadow
    2.56 -		echo "root:x:0:" > etc/group
    2.57 -		echo "root:*::" > etc/gshadow
    2.58 +
    2.59 +		# /etc files.
    2.60 +		cp -f /etc/slitaz-release $root/etc
    2.61 +		if [ ! -f "$root/etc/passwd" ]; then
    2.62 +			echo "root:x:0:0:root:/root:/bin/sh" > $root/etc/passwd
    2.63 +			echo "root::13525:0:99999:7:::" > $root/etc/shadow
    2.64 +			echo "root:x:0:" > $root/etc/group
    2.65 +			echo "root:*::" > $root/etc/gshadow
    2.66 +		fi
    2.67 +
    2.68 +		# /dev nodes.
    2.69  		#mknod -m 666 $root/dev/null c 1 3
    2.70 -		
    2.71 -		gettext "Setting files permissions..."
    2.72 -		chmod 640 etc/shadow etc/gshadow
    2.73 -		chmod 0700 root && chmod 1777 tmp
    2.74 +
    2.75 +		# Ssfs Busybox package install files in $cache and allow easy vdisk
    2.76 +		# upgrade folowing SliTaz repo.
    2.77 +		gettext "Installing Ssfs Busybox..."
    2.78 +		cp -a $rootfs/* $root
    2.79  		status
    2.80  
    2.81 +<<<<<<< local
    2.82 +		gettext "Setting files permissions..."
    2.83 +		chmod 0640 $root/etc/*shadow
    2.84 +		chmod 0700 $root/root && status
    2.85 +		chmod 4755 $root/bin/busybox
    2.86 +=======
    2.87  		# Busybox without deps (get && extract). No system comands are allowed
    2.88  		# in /etc/busybox.conf to restrict SSH'd users.
    2.89  		gettext "Installing Busybox..."
    2.90 @@ -265,8 +289,8 @@
    2.91  			> $root/etc/busybox.conf
    2.92  		echo -e "\n[SUID]" >> $root/etc/busybox.conf
    2.93  		echo -e "su = --- root.root" >> $root/etc/busybox.conf
    2.94 +>>>>>>> other
    2.95  		chmod 0600 $root/etc/busybox.conf
    2.96 -		status
    2.97  
    2.98  		# Glib minimal libs, use host lib since package should be installed
    2.99  		# from same repo.
   2.100 @@ -274,12 +298,19 @@
   2.101  		for l in  ld-*.*so* libc-*.*so libc.so.* libnss_files*
   2.102  		do
   2.103  			cp -a /lib/$l* $root/lib
   2.104 -		done && chmod 0644 $root/lib/* && status
   2.105 +		done && status
   2.106  		
   2.107  		# Ssfs chroot SHell
   2.108  		gettext "Installing Ssfs SHell..."
   2.109  		install -m 0755 /bin/ssfs-sh $root/bin
   2.110  		status
   2.111 +
   2.112 +		# List of all system files.
   2.113 +		cd $root
   2.114 +		for d in bin etc lib sbin
   2.115 +		do
   2.116 +			find ./$d | sed s'/^.//'
   2.117 +		done
   2.118  		
   2.119  		size=$(du -sh $root | awk '{print $1}')
   2.120  		separator
   2.121 @@ -303,19 +334,19 @@
   2.122  		separator && echo "" ;;
   2.123  	clean-vdisk)
   2.124  		# clean up the vdisk storage chroot.
   2.125 -		if [ ! -d "$root/bin" ] || [ ! -d "$root/usr" ]; then
   2.126 +		if [ ! -d "$root/bin" ] || [ ! -d "$root/lib" ]; then
   2.127  			gettext -e "No chroot found in:"; echo " $root"
   2.128  			exit 0
   2.129  		fi
   2.130  		gettext -e "\nCleaning virtual disk\n"
   2.131  		separator
   2.132 -		gettext "Changing directory to:"; echo " $root"
   2.133 +		echo "Chroot path: $root"
   2.134  		cd $root
   2.135  		for dir in *
   2.136  		do
   2.137  			size=$(du -sh $dir | awk '{print $1}')
   2.138  			case "$dir" in
   2.139 -				home|root|lost*)
   2.140 +				etc|home|root|lost*)
   2.141  					gettext "Skipping:"; echo " $dir $size *" ;;
   2.142  				*)
   2.143  					gettext "Removing:"; echo " $dir $size"
     3.1 --- a/ssfs-sh	Sun Jun 12 12:02:48 2011 +0100
     3.2 +++ b/ssfs-sh	Sun Jun 12 13:31:26 2011 +0200
     3.3 @@ -19,7 +19,7 @@
     3.4  	HOME=/home/$USER
     3.5  	SYNC=$HOME/Sync
     3.6  	SHELL=/bin/sh
     3.7 -	PS1='\u@ssfs:\e[1;33m\w\e[0m\$ '
     3.8 +	PS1="$USER@ssfs:\w$ "
     3.9  	export HOME SYNC SHELL PS1
    3.10  	cd $HOME && exec /bin/sh $@
    3.11  fi
     4.1 --- a/web/ssfs.cgi	Sun Jun 12 12:02:48 2011 +0100
     4.2 +++ b/web/ssfs.cgi	Sun Jun 12 13:31:26 2011 +0200
     4.3 @@ -5,7 +5,7 @@
     4.4  
     4.5  . /etc/ssfs/ssfs-server.conf
     4.6  
     4.7 -notes=/var/cache/ssfs/notes
     4.8 +notes=/var/lib/ssfs/notes
     4.9  root=$SSFS_CHROOT
    4.10  vdisk=$(basename $SSFS_VDISK)
    4.11  vsize=$(du -sh $SSFS_VDISK | awk '{print $1}')