Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 17 Nov 2003 20:13:51 +0600 (NOVT)
From:      "Rashid N. Achilov" <shelton@sentry.granch.ru>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   ports/59371: new port: smb4k, KDE SMB network browser and SMB shares manager
Message-ID:  <200311171413.hAHEDpq6065859@sentry.granch.ru>
Resent-Message-ID: <200311171420.hAHEKL8C055520@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         59371
>Category:       ports
>Synopsis:       new port: smb4k, KDE SMB network browser and SMB shares manager
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Mon Nov 17 06:20:20 PST 2003
>Closed-Date:
>Last-Modified:
>Originator:     Rashid N. Achilov
>Release:        FreeBSD 4.9-STABLE i386
>Organization:
Granch Ltd.
>Environment:
System: FreeBSD sentry.granch.ru 4.9-STABLE FreeBSD 4.9-STABLE #19: Mon Nov 10 16:22:38 NOVT 2003 shelton@sentry.granch.ru:/usr/src/sys/compile/Sentry i386
>Description:
This is a SMB4K, a KDE 3.x SMb shares manager and SMB network browser. It is a mostly
featured program to browse Windows/Samba Network and manage Windows/Samba shares on
your box. Features of this program makes it mostly closed to Windows
'Network Neigborhood'.
>How-To-Repeat:
>Fix:
# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
#	smb4k
#	smb4k/Makefile
#	smb4k/distinfo
#	smb4k/pkg-descr
#	smb4k/pkg-plist
#	smb4k/pkg-message
#	smb4k/files
#	smb4k/files/smb2awk
#	smb4k/files/smb2nsmbrc
#	smb4k/files/smbmount
#	smb4k/files/smbumount
#	smb4k/files/README.FreeBSD
#
echo c - smb4k
mkdir -p smb4k > /dev/null 2>&1
echo x - smb4k/Makefile
sed 's/^X//' >smb4k/Makefile << 'END-of-smb4k/Makefile'
X# New ports collection makefile for:	smb4k
X# Date created:				17 Nov 2003
X# Whom:					Rashid N. Achilov <shelton@granch.ru>
X#
X# $FreeBSD$
X#
X
XPORTNAME=		smb4k
XPORTVERSION=		0.3.1
XCATEGORIES=		net kde
XMASTER_SITES=		http://download.berlios.de/smb4k/ \
X			ftp://ftp.berlios.de/pub/smb4k/unsupported/FreeBSD/
X
XMAINTAINER=		shelton@granch.ru
XCOMMENT=		KDE 3.x SMB Network browser and SMB shares mounting center
X
XRUN_DEPENDS=		sudo:${PORTSDIR}/security/sudo
X
X.if defined(WITH_SAMBA3)
XRUN_DEPENDS+=		smbstatus:${PORTSDIR}/net/samba-devel
X.else
XRUN_DEPENDS+=		smbstatus:/${PORTSDIR}/net/samba
X.endif
X
XUSE_KDELIBS_VER=	3
XUSE_GMAKE=		yes
XUSE_REINPLACE=		yes
XGNU_CONFIGURE=		yes
X
XCONFIGURE_ARGS += 	--with-qt-dir=${QT_PREFIX} \
X			--with-extra-includes=${LOCALBASE}/include \
X			--with-extra-libs=${LOCALBASE}/lib
X
XCONFIGURE_TARGET=
X
XDOCSDIR=		${PREFIX}/share/doc/HTML/en/${PORTNAME}
X
XPLIST_SUB=		DOCSDIR=${DOCSDIR}
X
Xpre-configure:
X			@${ECHO_MSG} ""
X			@${ECHO_MSG} "For use with Samba 3.x branch use WITH_SAMBA3=yes"
X			@${ECHO_MSG} "(press Ctrl-C now and start make WITH_SAMBA3=yes)"
X			@${ECHO_MSG} ""
X			@sleep 2
X
Xpost-install:
X
X.for i in smb2awk smb2nsmbrc smbmount smbumount
X	${INSTALL_SCRIPT} ${FILESDIR}/${i} ${PREFIX}/bin
X.endfor
X
X			${INSTALL_DATA} ${FILESDIR}/README.FreeBSD ${DOCSDIR}
X
X			@${CAT} ${PKGMESSAGE}
X
X.include <bsd.port.mk>
END-of-smb4k/Makefile
echo x - smb4k/distinfo
sed 's/^X//' >smb4k/distinfo << 'END-of-smb4k/distinfo'
XMD5 (smb4k-0.3.1.tar.gz) = 90943df82a0e04117f1c95537ea76a0c
END-of-smb4k/distinfo
echo x - smb4k/pkg-descr
sed 's/^X//' >smb4k/pkg-descr << 'END-of-smb4k/pkg-descr'
XSmb4K is an SMB share browser for KDE. Its features are inspired by Komba2
Xby Frank Schwanz. It uses the Samba software suite for an easy access
Xto the SMB shares of your local network neighborhood.
X
XFeatures so far:
X
XScanning for (active) workgroups, hosts, and shares
XMounting and unmounting of SMB shares, including unmounting all shares at once
XAccess to the files of a mounted SMB share using Konqueror
XAuto-detection of external mounts/unmounts
XMounting of recently used shares on start-up
XMiscellaneous infos about the SMB shares
XBasic network search
XWINS server support
XPreview of SMB shares
XSelectable look-up method
XTranslations: German, Catalan, Swedish, Polish, Chinese Simplified, Russian
X
XWWW: http://smb4k.berlios.de
END-of-smb4k/pkg-descr
echo x - smb4k/pkg-plist
sed 's/^X//' >smb4k/pkg-plist << 'END-of-smb4k/pkg-plist'
Xbin/smb4k
Xbin/smb2awk
Xbin/smb2nsmbrc
Xbin/smbmount
Xbin/smbumount
Xshare/applnk/Applications/smb4k.desktop
Xshare/icons/crystalsvg/16x16/apps/smb4k.png
Xshare/icons/crystalsvg/32x32/apps/smb4k.png
Xshare/icons/crystalsvg/48x48/apps/smb4k.png
Xshare/icons/crystalsvg/64x64/apps/smb4k.png
Xshare/apps/smb4k/smb4kui.rc
Xshare/locale/ru/LC_MESSAGES/smb4k.mo
Xshare/locale/zh_CN/LC_MESSAGES/smb4k.mo
Xshare/locale/ca/LC_MESSAGES/smb4k.mo
Xshare/locale/de/LC_MESSAGES/smb4k.mo
Xshare/locale/pl/LC_MESSAGES/smb4k.mo
Xshare/locale/sv/LC_MESSAGES/smb4k.mo
X%%PORTDOCS%%%%DOCSDIR%%/index.docbook
X@dirrm share/apps/smb4k
X%%PORTDOCS%%@dirrm %%DOCSDIR%%
X@unexec rmdir %D/share/applnk/Applications 2>/dev/null || true
X@unexec rmdir %D/share/applnk 2>/dev/null || true
END-of-smb4k/pkg-plist
echo x - smb4k/pkg-message
sed 's/^X//' >smb4k/pkg-message << 'END-of-smb4k/pkg-message'
X***********************************************************
X
XPlease, read README.FreeBSD in share/doc/HTML/en/smb4k in your KDE
Xprefix directory first!
X
XIn order to run SMB4K properly be sure, that:
X
X1. Your kernel is configured properly
X2. Your /etc/nsmb.conf file is configured properly
X3. User allowed to run mount_smbfs amd umount
X4. Your .nsmbrc file is configured properly (this mean, that
Xpassword to *ANY* server in your network exist this file. For
Xsemi-automatic creating .nsmbrc you can use smb2nsmbrc script)
X
XKeep in mind, that:
X
X1. SMB4K only calls smbmount and smbumount programs.
X2. You can use presented scripts or create yourself.
X3. DO NOT DISTURB ME ABOUT FreeBSD SMB IMPLEMENTATION!!
X
XWhen some goes wrong, look in .smbhistory in user home directory
X
X************************************************************
END-of-smb4k/pkg-message
echo c - smb4k/files
mkdir -p smb4k/files > /dev/null 2>&1
echo x - smb4k/files/smb2awk
sed 's/^X//' >smb4k/files/smb2awk << 'END-of-smb4k/files/smb2awk'
X#!/usr/bin/awk -f
X# AWK part for generating Windows/Samba boxes list in .nsmbrc format
X# Incoming - findsmb output, outgoing - NetBIOS names list
X# $Id: smb2awk,v 1.2 2003/10/30 09:41:10 shelton Exp $
X
X{
X  while ((getline nline) > 0)
X   {
X     if (substr(nline,1,1) == "-")
X       {
X         sig = 1
X         continue
X       }
X
X     if (sig == 0)
X       continue
X      else
X        {
X          split(nline,narray," ")
X
X          if (narray[2] == "unknown")
X            next
X           else
X             if (index(narray[2],".") != 0)
X               next
X              else
X                 print narray[2]
X        }
X   }
X}
END-of-smb4k/files/smb2awk
echo x - smb4k/files/smb2nsmbrc
sed 's/^X//' >smb4k/files/smb2nsmbrc << 'END-of-smb4k/files/smb2nsmbrc'
X#!/bin/sh
X# Convert list of Windows/Samba boxes in local network to .nsmbrc format
X# Args, if any passed directly to findsmb - network address and broadcast address
X# $Id: smb2nsmbrc,v 1.3 2003/10/30 09:41:10 shelton Exp $
X
Xfind="findsmb"			# Script to display boxes list
Xutil="smbutil"			# Utility to convert plaintext password to hashed
Xoutfile=".nsmbrctmp"		# Generated file name
X
X# First, we check on presence findsmb
Xwfind=`whereis -b $find | awk '{print $2}'`
X
Xif [ -z $wfind ]; then
X  echo FindSMB did not found in your system, please install samba package first
X  exit 5
Xfi
X
X# Second, we check on presence smbutil
Xwutil=`whereis -b $util | awk '{print $2}'`
X
Xif [ -z $wfind ]; then
X  echo SMBUtil did not found in your system, please install samba package first
X  exit 5
Xfi
X
X# Now we ask username
Xecho -n "Please enter username (UPPER CASE!): "
Xread username
X
X# Now we ask password and crypt by smbutil
Xpassword=`$util crypt`
X
X# Now we detect all Windows/Samba boxes and taking their NetBIOS names
Xnetnames=`findsmb $1 $2 | awk -f smb2awk`
X
X# And at least we generating temporarly file with username, password and
X# sections for all detected boxes
Xfor netname in $netnames
X do
X  echo "[$netname:$username]" >> $outfile
X  echo "password=$password" >> $outfile
X  echo "" >> $outfile
X done
END-of-smb4k/files/smb2nsmbrc
echo x - smb4k/files/smbmount
sed 's/^X//' >smb4k/files/smbmount << 'END-of-smb4k/files/smbmount'
X#!/bin/sh
X# $Id: smbmount,v 1.6 2003/10/30 11:23:38 shelton Exp $
X# SMB mounting wrapper for working with SMB4K KDE package
X
X# Variable part
Xlog=".smbhistory"				# Mount log location
Xcodefrom="koi8-r"				# Codepage from converting
Xcodeto="cp866"					# Codepage to converting
Xsmbrc=".nsmbrc"					# Personal SMB rc file
Xpasswd="/etc/passwd"				# User list
X
X#echo $@ > /tmp/tralala
X
X# Taking user ID
Xid=`id -un`
X
X# Take username=<username>
Xuname=`echo $4 | awk 'BEGIN {FS=","} {print $2}'`
X
X# Take username, when it isn't "guest"
Xif [ ! $uname = "guest" ]; then
X  runame=`echo $uname | awk 'BEGIN {FS="="} {print $2}'`
X else
X   runame="guest"
Xfi
X
X# Take server name
Xserver=`echo $1 | awk 'BEGIN {FS="/"} {print $3}'`
X
X# Take share name
Xshare=`echo $1 | awk 'BEGIN {FS="/"} {print $4}'`
X
X# When codepages didn't specified, empty arg, else generate
Xif [ -z $codefrom ] && [ -z $codeto ]; then
X  conv=""
X else
X   conv="-E $codefrom:$codeto"
Xfi
X
X# Find username and construct homedir path
Xuhome=`grep $id $passwd | awk 'BEGIN {FS=":" } {print $6}'`
Xplog="$uhome/$log"
X
X# Check on args presence
Xif [ $# -eq 0 ]; then
X  stamp=`date +"%D %T"`
X  echo "$stamp Mount point did not specified" >> $plog
X  exit
Xfi
X
X# Check on presence password in personal SMB rc file
Xsmark=`grep -i "$server:$id" $uhome/$smbrc`
X
Xif [ -z $smark ]; then
X  echo "$stamp $server did not found in $uhome/$smbrc file, please run smb2nsmbrc first" >> $plog
X  exit
Xfi
X
X# Do mount
X# When this is root, silently do
Xif [ $id = "root" ]; then
X  stamp=`date +"%D %T"`
X  echo "$stamp mount_smbfs $conv //$runame@$server/$share $2" >> $plog
X  mount_smbfs $conv //$runame@$server/$share $2
X  exit
Xfi
X
X# Pasring mount point. When 2nd or 3rd args are compared with username
X# (so, /home/<username> or /usr/home/<username> exist) - doing umount, else nothing
Xsep2=`echo $2 | awk 'BEGIN {FS="/"} {print $3}'`
Xsep3=`echo $2 | awk 'BEGIN {FS="/"} {print $4}'`
X
X# When $sep2 empty - error (we tried to mount / :-)))
Xif [ -z $sep2 ]; then
X  stamp=`date +"%D %T"`
X  echo "$stamp No permissions to mount $2, mount request ignored" >> $plog
X  exit
Xfi
X
Xif [ ! $id = $sep2 ]; then
X  notsep2=1
X else
X   notsep2=0
Xfi
X
X# When $sep3 is empty, and sep2 not equal userhome - error
Xif [ -z $sep3 ] && [ $notsep2 -eq 1 ]; then
X  stamp=`date +"%D %T"`
X  echo "$stamp No permissions to mount $2, mount request ignored" >> $plog
X  exit
Xfi
X
X# When sep2 AND sep3 not equal userhome - error
Xif [ ! $id = $sep3 ] && [ $notsep2 -eq 1 ]; then
X  stamp=`date +"%D %T"`
X  echo "$stamp No permissions to mount $2, mount request ignored" >> $plog
X  exit
Xfi
X
Xstamp=`date +"%D %T"`
Xecho "$stamp sudo mount_smbfs $conv //$runame@$server/$share $2" >> $plog
Xsudo mount_smbfs $conv //$runame@$server/$share $2
END-of-smb4k/files/smbmount
echo x - smb4k/files/smbumount
sed 's/^X//' >smb4k/files/smbumount << 'END-of-smb4k/files/smbumount'
X#!/bin/sh
X# Wrapper to umount SMB Windows/Samba shares
X# $Id: smbumount,v 1.3 2003/10/30 10:52:42 shelton Exp $
X
X# Variable part
Xlog=".smbhistory"				# Mount log location
Xpasswd="/etc/passwd"				# User list
X
X# Taking user ID
Xid=`id -un`
X
X# Find username and construct homedir path
Xuhome=`grep $id $passwd | awk 'BEGIN {FS=":"} {print $6}'`
Xplog="$uhome/$log"
X
X# Check on args presence
Xif [ $# -eq 0 ]; then
X  stamp=`date +"%D %T"`
X  echo "$stamp Mount point did not specified" >> $plog
X  exit
Xfi
X
X# Checking about SMB filesystem. When filesystem didn't found - not mounted
Xfstype=`mount | grep -iw "$1 " | awk 'BEGIN {FS="("} {print $2}' | \
X	  				awk 'BEGIN {FS=","} {print $1}'`
X
Xif [ -z $fstype ]; then
X  stamp=`date +"%D %T"`
X  echo "$stamp $1 not mounted, umount request ignored" >> $plog
X  exit
X else
X   if [ ! $fstype = "smbfs)" ]; then
X     stamp=`date +"%D %T"`
X     echo "$stamp $1 is not SMB filesystem, umount request ignored" >> $plog
X     exit
X   fi
Xfi
X
X# When this is root, silently do
Xif [ $id = "root" ]; then
X  stamp=`date +"%D %T"`
X  echo "$stamp umount $1" >> $log
X  umount $1
X  exit
Xfi
X
X# Pasring mount point. When 2nd or 3rd args are compared with username
X# (so, /home/<username> or /usr/home/<username> exist) - doing umount, else nothing
Xsep2=`echo $1 | awk 'BEGIN {FS="/"} {print $3}'`
Xsep3=`echo $1 | awk 'BEGIN {FS="/"} {print $4}'`
X
X# When $sep2 empty - error (we tried to umount / :-)))
Xif [ -z $sep2 ]; then
X  exit
Xfi
X
Xif [ ! $id = $sep2 ]; then
X  notsep2=1
X else
X   notsep2=0
Xfi
X
X# When $sep3 is empty, and sep2 not equal userhome - error
Xif [ -z $sep3 ] && [ $notsep2 -eq 1 ]; then
X  stamp=`date +"%D %T"`
X  echo "$stamp No permissions to umount $2, mount request ignored" >> $plog
X  exit
Xfi
X
X# When sep2 AND sep3 not equal userhome - error
Xif [ ! $id = $sep3 ] && [ $notsep2 -eq 1 ]; then
X  stamp=`date +"%D %T"`
X  echo "$stamp No permissions to umount $2, mount request ignored" >> $plog
X  exit
Xfi
X
X# Unmounting point lies in userspace
Xstamp=`date +"%D %T"`
Xecho "$stamp sudo umount $1" >> $plog
Xsudo umount $1
END-of-smb4k/files/smbumount
echo x - smb4k/files/README.FreeBSD
sed 's/^X//' >smb4k/files/README.FreeBSD << 'END-of-smb4k/files/README.FreeBSD'
X		    SMB mounting in FreeBSD with SMB4K
X                    ----------------------------------
X                    $Id: README.FreeBSD,v 1.2 2003/10/30 11:23:38 shelton Exp $
X
X1. Preface
X----------
X
XThis document describes, how to coordinate SNB4K (initially Linux-only program)
Xand FreeBSD implementation of SMBFS. This document assumed, that you already
Xhave working SMBFS in your kernel (see man mount_smbfs(8), FreeBSD Handbook
Xchapter 9 and an sample kernel config file part below:
X
X#
X# SMB/CIFS requester
X# NETSMB enables support for SMB protocol, it requires LIBMCHAIN and LIBICONV
X# options.
X# NETSMBCRYPTO enables support for encrypted passwords.
Xoptions         NETSMB                  #SMB/CIFS requester
Xoptions         NETSMBCRYPTO            #encrypted password support for SMB
X
X# mchain library. It can be either loaded as KLD or compiled into kernel
Xoptions         LIBMCHAIN               #mbuf management library
Xoptions         SMBFS                   #SMB/CIFS filesystem
X# Kernel side iconv library
Xoptions         LIBICONV
X
XYou need all these for working SMBFS) and /etc/nsmb.conf configured properly
X(in spite of that nsmb.conf has all variables 'transparent', documentation
Xabout SMBFS tuning in FreeBSD are very, very shy :-( You should setup at least
Xparemeters "workgroup" and "nbns". As nbns you should set your WINS server
X(as called it in Microsoft world).
X
X2. After setup, but before first run
X------------------------------------
X
XSo, you has just setup SMB4K. What should you do to properly mounting SMB
Xshares? You should do some things.
X
Xa. Remember, that SMB4K didn't mount shares itself. Instead of that, it
Xcalled 'smbmount' (next releases you'll can setup, what will called) with
Xsome set of parameters: server and share path in //server/share format,
Xmount point in /home/dir/dir2 format and parameters string, prefaced keyword
X'-o'. Parameters are username=<username>, password=<password>,
Xworkgroup=<workgroup>. Also, SMB4K didn't umount shares itself. Instead of
Xthis it called 'smbumount' (next releases you'll can setup, what will called)
Xwith single parameter - mount point. Because FreeBSD hasn't smbmount and
Xsmbumount programs, I have developed some set of scripts, which acted as
Xwrappers - it takes parameters from SMB4K and calling mount_smbfs to do
Xmounting.
X
Xb. Before start SMB4K first time, you should setup your .nsmbrc file
Xproperly. For my pity, you must setup each Windows/Samba box in your network
XSEPARATELY. No default usernames, no domain logons. Looks sadly, aren't you?
Xsmb2nsmbrc script sligtly takes this job from you. You start smb2nsmbrc, it
Xcalled findsmb (of course, you should have findsmb and smbutil in your path),
Xparsing their output, asks you about username, password and stored file
X.nsmbrctmp in current directory with pairs
X
X[SERVERNAME:USERNAME]
Xpassword=<encrypted password>
X
XEncryption done with smbutil and ready for use with mount_smbfs. Findsmb takes
Xyour first network interface, so, when you have a box with some network cards,
Xstart smb2nsmbrc with two parameters - network address and broadcast address.
XThese parameters will passed directly to findsmb. When .nsmbrctmp file already
Xexist it will added, not replaced! Simply add .nsmbrctmp content to your .nsmbrc
Xfile in your home directory
X
Xc. You should have a 'sudo' package to do mounting/umounting and your login
Xshould be authorized to run mount_smbfs and umount. Sample part of sudoers file
Xsee below (shelton - this is my login):
X
X# Host alias specification
XHost_Alias      SENTRY = sentry
X
X# To mount SMB shares inside SMB4K
Xshelton         SENTRY = (root) NOPASSWD: /sbin/mount_smbfs
Xshelton         SENTRY = (root) NOPASSWD: /sbin/umount
X
XSo, user shelton from box sentry will authorized to run /sbin/mount_smbfs and
X/sbin/umount without asking a password. More info about sudoers file see man
Xsudoers(5))
X
X3. Inside running SMB4K
X-----------------------
X
XWhen you have done all previous steps properly (it looks quite difficult, but
XPLEASE, do not ask me, ask SMBFS developers, why), you should see files in
Xmounted share, when you click on it in SMB4K window. When you see empty
Xdirectory (and really this directory keeps files), check your .smbhistory
Xfile in your home directory - it keeps all messages about finished and
Xunfinished actions and error messages. You should have SMBFS in your kernel,
Xyou should have propelry nsmb.conf, you should have properly .nsmbrc (keep
Xin mind - all server and user names in UPPER case!) with presented pairs
X[server:user] about EACH server and EACH user (so, when you have two logins
Xalice and bob and two server alpha and beta, you should have 4 entries in
X.nsmbrc - [ALICE:ALPHA], [ALICE:BETA], [BOB:ALPHA] and [BOB:BETA]). When
Xall these dobe, but mount unsuccesful, try to mount this share manually.
XAlso you can uncomment string
X
Xecho $@ > /tmp/tralala
X
Xat start of smbmount script and looks, how passed a mount arguments in file
X/tmp/tralala.
X
X4. Feedback
X-----------
X
XAll these scripts and this readme file were written by Rashid N. Achilov
X(shelton@granch.ru). So, you can ask me about their working and also about
Xany other SMB shares mounting errors, but keep in mind - Im' NOT A SMBFS
XDEVELOPER. To ask with serious problems, please mail to SMB developer:
XBoris Popov <bp@freebsd.org>.
END-of-smb4k/files/README.FreeBSD
exit
>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200311171413.hAHEDpq6065859>