This file is indexed.

/usr/sbin/update-dpsyco-users-samba is in dpsyco-samba 1.0.36.

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
#!/bin/sh
# DocumentId:	$Id: update-dpsyco-users-samba 2318 2006-07-19 17:58:05Z ola $
# Author:	$Author: ola $
# Date:		$Date: 2006-07-19 19:58:05 +0200 (ons, 19 jul 2006) $
# Summary:
#	Updates the shell accounts.
#
# Copyright (C) 2001-2004 Ola Lundqvist <opal@debian.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#

# Read the default dpsyco config.
. /etc/dpsyco/defaults.conf
. /usr/share/dpsyco/change.func
. /usr/share/dpsyco/owner.func

removesmbuser() {
    smbpasswd -x $1
    dpsyco-delsmbprofile $1
}

restoresmbuser() {
    dpsyco-restoresmbprofile $1
}

TESTNFS="/ $DHOME /etc"
. /usr/share/dpsyco/checknfs.test

# Users that should have shell access.
FUSERS=$(find $USERSRC -maxdepth 3 -path "$USERSRC/*/*" -type f -name "samba" | sed -e "s|/samba||;" | sed -e "s|.*/||;" | sort -u)

if [ ! -e $SMBF ] ; then
    if [ ! -z "$FUSERS" ] ; then
	echo "# SMB password file, generated by update-dpsyco-users-samba." > $SMBF
	chown 600 $SMBF
    else
	echo "No samba users to configure, skipping."
	exit 0
    fi
fi

# Users that exist in smbpassword file.
# NOTE! This line has to be after FUSERS= and the $SMBF checking routine.
EUSERS=$(grep "^[^:]*:$UID_MATCH:" $SMBF | sed -e "s|:.*||g;")

# When removing a user do the following:
# smbpasswd -x $USER

for RU in $EUSERS ; do
    UPID=$(grep "^$RU:" $PWDF | sed -e "s|^[^:]*:[^:]*:\([^:]*\):.*|\1|;")
    if [ -z "$UPID" ] ; then
	echo "Del user $RU from samba, removed form passwd file."
	removesmbuser $RU
    elif [ $UPID -gt $LAST_UID ] ; then
	echo "User $RU is a ordinary user and should not be removed."
	echo "THIS SHOULD NEVER HAPPEN, error in update script."
    elif [ $UPID -lt $FIRST_UID ] ; then
	echo "User $RU is a system user and should not be removed."
	echo "THIS SHOULD NEVER HAPPEN, error in update script."
    elif ! echo "$FUSERS" | grep "^$RU$" > /dev/null 2>&1 ; then
	echo "Del user $RU from samba."
	removesmbuser $RU
    fi
done

# Users that exist in smbpassword file.
EUSERS=$(grep "^[^:]*:[^:]*:$UID_MATCH:" $SMBF | sed -e "s|:.*||g;")

# Modify the user information for all users that should and do exist.
for U in $FUSERS ; do
    . $USERSC
    if [ -f $USERSRC/$U ] ; then
	. $USERSRC/$U
    fi
    if [ ! -z "$SMBCRYPT" ] ; then
	SMBCRT=$(echo "$SMBCRYPT" | sed -e "s|:.*||;")
	# User should have samba access.
	UPID=$(grep "^$U:" $PWDF | sed -e "s|^[^:]*:[^:]*:\([^:]*\):.*|\1|;")
	if ! grep "^$U:" $SMBF > /dev/null 2>&1 ; then
	    echo "Adding user $U to smbpasswd."
	    echo "$U:$UPID:$SMBCRYPT" >> $SMBF
	    restoresmbuser $U
	elif ! grep "^$U:$UPID:$SMBCRT" $SMBF > /dev/null 2>&1 ; then
	    echo "Updating password and/or UID for user $U."
	    SMBCR=$(echo "$SMBCRYPT" | sed -e "s/|/\\|/g;")
	    changefile "s|^\($U\):[0-9]*:.*|\1:$UPID:$SMBCR|;" $SMBF
	else
	    # User should not have samba access.
	    if ! grep "^$U:" $SMBF > /dev/null 2>&1 ; then
		echo "Samba not enabled for $U, removing user from smbpasswd."
		removesmbuser $U
	    fi
	fi
	if [ -e /etc/samba/smb.conf ] ; then
	    if grep "^$U:" $SMBF > /dev/null 2>&1 ; then
		# User should exist and 
		cat /etc/samba/smb.conf | grep -A 20 "^[[:space:]]*\[profiles\]" | grep -B 20 "^[[:space:]]*\[[^p]" | grep "^[[:space:]]*path[[:space:]]*=[[:space:]]*" | sed -e "s|^[[:space:]]*path[[:space:]]*=[[:space:]]*||;" | {
		    read PROFPATH
		    if [ ! -z "$PROFPATH" ] ; then
			changeowner $U $U $PROFPATH/$U
		    fi
		}
	    fi
	fi
    else
	# User should not have samba access.
	if grep "^$U:" $SMBF > /dev/null 2>&1 ; then
	    echo "No SMBCRYPT info for $U, removing user from smbpasswd."
	    removesmbuser $U
	fi
    fi
done