This file is indexed.

/usr/bin/sftp-user is in mysecureshell 2.0-1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
#!/bin/sh

## Users Script Manager v0.2 - Made by MySecureShell Team
## MySecureShell Team <teka2nerdman@users.sourceforge.net>

# Saving vars
nameuser=$2
hideuser=$3
bindir='/usr/bin';

# OS Detection
osdetection=`uname -s`

# Error messages
badarg="Sorry but you gave me a bad argument !"
alreadyexist="Sorry but this user already exist !"
doesntexist="Sorry but this user doesn't exist !"

##########################
## User sftp-user verif ##
##########################
encPass='*'

vrf_create() {
	for i in "$nameuser" ; do
		if [ -z "$i" ] ; then
			echo $bardarg
			exit 0
		fi
	done
}

vrf_delhide() {
	name=`id -un $nameuser 2>&1`
	if [ "$name" = 'nobody' ] || [ "$name" = "$nameuser" ] ; then
		break
	else
		echo $doesntexist
		exit 1
	fi
}

vrf_getpass() {
	dirPerl=
	for dir in `echo $PATH | tr : "\n"` ; do
		if [ -x $dir/perl ] ; then
			dirPerl=$dir;
			break
		fi
	done
	if [ "$dirPerl" != '' ] ; then
		echo "Enter password:"
		stty -echo
		read pass
		stty echo
		echo
		encPass=`$dirPerl/perl <<EOF
my \\$itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
my \\$salt = '';
for (1..2) { \\$salt .= substr \\$itoa64, rand(length(\\$itoa64)), 1; }
print crypt("$pass", \\$salt);
EOF`
	else
		echo "Please install 'perl' to have full features of $0";
		echo "Or use the commande 'passwd {user}' to set the password of the user"
	fi
}

vrf_useralreadyexit() {
	name=`id -un $nameuser 2>&1`
	if [ "$name" = "$nameuser" ] || [ "$name" = 'nobody' ] ; then
		echo $alreadyexist
		exit 1
	fi
}

##########################
## Darwin users manager ##
##########################

# Creation
dar_add() {
	if [ -x /usr/bin/niutil ] ; then
		newid=$[`nireport / /users uid | tail -1`+1]
		# Add User
		niutil -create -R / /users/$nameuser
		#Check if success
		test $? != 0 && exit $?
		niutil -createprop -R / /users/$nameuser passwd "$encPass"
		niutil -createprop -R / /users/$nameuser gid $newid
		niutil -createprop -R / /users/$nameuser uid $newid
		niutil -createprop -R / /users/$nameuser realname "$nameuser"
		niutil -createprop -R / /users/$nameuser shell "$bindir/mysecureshell"
		niutil -createprop -R / /users/$nameuser picture "/Library/Caches/com.sourceforge.mysecureshell.picture.tiff"
		#niutil -createprop -R / /users/$nameuser home "/Users/invite"
		# Home create future versions
		#cp -R /System/Library/User\ Template/French.lproj /Users/$nameuser
		#chown -R $nameuser:staff /Users/$nameuser
	fi

	if [ -x /usr/bin/dscl ] ; then
		dscl . -create /Users/$nameuser
		dscl . -create /Users/$nameuser UserShell "$bindir/mysecureshell"
		dscl . -create /Users/$nameuser RealName "$nameuser"
		dscl . -passwd /Users/$nameuser "$encPass"
		dscl . -append /Groups/staff GroupMembership $nameuser
	fi
	# Hide user
	test "$hideuser" = '1' && defaults write /Library/Preferences/com.apple.loginwindow HiddenUsersList -array $nameuser && defaults write /Library/Preferences/com.apple.loginwindow HiddenUsersList -array-add $nameuser
}

# List users with MySecureShell Shell
dar_list() {
	if [ -x /usr/bin/nireport ] ; then
		nireport / /users name shell | grep /mysecureshell | awk '{ print $1 }'
	fi

	if [ -x /usr/bin/dscl ] ; then
		dscl . -list /Users shell | grep mysecureshell | awk '{ print $1 }'
	fi
	exit $?
}

# Deletion
dar_del() {
	if [ -x /usr/bin/niutil ] ; then
		niutil -destroy -R / /users/$nameuser
	fi

	if [ -x /usr/bin/dscl ] ; then
		dscl . delete /Users/$nameuser
	fi
	exit $?
}

# Hidding
dar_hid() {
	# Home is choice
	if [ "$hideuser" = '0' ] ; then
		defaults write /Library/Preferences/com.apple.loginwindow HiddenUsersList $nameuser
	else
		defaults write /Library/Preferences/com.apple.loginwindow HiddenUsersList -array $nameuser
		defaults write /Library/Preferences/com.apple.loginwindow HiddenUsersList -array-add $nameuser
	fi
	exit $?
}


#########################
## Linux users manager ##
#########################

# Creation
nux_add() {
	useradd -p $encPass -s $bindir/mysecureshell $nameuser
	exit $?
}

# Deletion
nux_list() {
	grep -F /mysecureshell /etc/passwd | cut -d: -f1
}

# Deletion
nux_del() {
	userdel -f $nameuser
	exit $?
}

###############
## User Menu ##
###############

case $1 in
	create)
		vrf_create
		vrf_useralreadyexit
		vrf_getpass
		if [ "$osdetection" = 'Darwin' ] ; then
			dar_add
		else
			nux_add
		fi
	;;
	delete)
		vrf_delhide
		if [ "$osdetection" = 'Darwin' ] ; then
			dar_del
		else
			nux_del
		fi
	;;
	list)
		if [ "$osdetection" = 'Darwin' ] ; then
			dar_list
		else
			nux_list
		fi
	;;
	hide)
		if [ "$osdetection" = 'Darwin' ] ; then
		    vrf_delhide
		    dar_hid
		fi
	;;
	*)
	echo "Usage 1: sftp-user create [user] [hide user]"
	echo "Usage 2: sftp-user delete [user]"
	echo "Usage 3: sftp-user list"
	echo "Usage 4: sftp-user hide [user] [hide] (Mac OS X Only)"
	echo ""
	echo ""
	echo "	Options		Choices		Descriptions"
	echo "	user		Username	User Name"
	echo "	hide user	1/0		hide user from login panel and user managements (Max OS X Only)"
	echo "	delete home	1/0		Remove user Home directory"
	echo "	hide		1/0		Hide/Unhide (Mac OS X Only)"
	;;
esac

exit 0