From b99ae5137471fad034dc7e98bc60cd2dc893b631 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 12 Jul 2005 16:34:44 +0000 Subject: r8384: merging clutter fixes from release branch (This used to be commit cbe74c09109dcfe93aa4af085920999ccbff34df) --- examples/debugging/README | 28 -- examples/debugging/solaris-oops.sh | 55 --- examples/genlogon/genlogon.pl | 71 ---- examples/logon/genlogon/genlogon.pl | 71 ++++ examples/logon/mklogon/mklogon.conf | 77 +++++ examples/logon/mklogon/mklogon.pl | 383 +++++++++++++++++++++ examples/logon/ntlogon/README | 160 +++++++++ examples/logon/ntlogon/ntlogon.conf | 44 +++ examples/logon/ntlogon/ntlogon.py | 376 ++++++++++++++++++++ examples/mklogon/mklogon.conf | 77 ----- examples/mklogon/mklogon.pl | 383 --------------------- examples/ntlogon/README | 160 --------- examples/ntlogon/ntlogon.conf | 44 --- examples/ntlogon/ntlogon.py | 376 -------------------- examples/scripts/backtrace | 41 --- examples/scripts/debugging/linux/backtrace | 41 +++ examples/scripts/debugging/solaris/README | 28 ++ examples/scripts/debugging/solaris/solaris-oops.sh | 55 +++ examples/scripts/perl/modify_samba_config.pl | 154 --------- examples/scripts/perl/smbaddprinter.pl | 41 --- examples/scripts/perl/smbdelprinter.pl | 27 -- examples/scripts/printing/cups/smbaddprinter.pl | 41 +++ examples/scripts/printing/cups/smbdelprinter.pl | 27 ++ examples/scripts/python/SambaConfig.py | 315 ----------------- examples/scripts/python/SambaParm.py | 84 ----- examples/scripts/python/generate_parm_table.py | 224 ------------ examples/scripts/python/modify_samba_config.py | 78 ----- examples/scripts/python/smbparm.py | 374 -------------------- .../scripts/shares/perl/modify_samba_config.pl | 154 +++++++++ examples/scripts/shares/python/SambaConfig.py | 315 +++++++++++++++++ examples/scripts/shares/python/SambaParm.py | 84 +++++ .../scripts/shares/python/generate_parm_table.py | 224 ++++++++++++ .../scripts/shares/python/modify_samba_config.py | 78 +++++ examples/scripts/shares/python/smbparm.py | 374 ++++++++++++++++++++ examples/svr4-startup/README | 24 -- examples/svr4-startup/samba.server | 38 -- 36 files changed, 2532 insertions(+), 2594 deletions(-) delete mode 100644 examples/debugging/README delete mode 100644 examples/debugging/solaris-oops.sh delete mode 100644 examples/genlogon/genlogon.pl create mode 100644 examples/logon/genlogon/genlogon.pl create mode 100644 examples/logon/mklogon/mklogon.conf create mode 100644 examples/logon/mklogon/mklogon.pl create mode 100644 examples/logon/ntlogon/README create mode 100644 examples/logon/ntlogon/ntlogon.conf create mode 100755 examples/logon/ntlogon/ntlogon.py delete mode 100644 examples/mklogon/mklogon.conf delete mode 100644 examples/mklogon/mklogon.pl delete mode 100644 examples/ntlogon/README delete mode 100644 examples/ntlogon/ntlogon.conf delete mode 100755 examples/ntlogon/ntlogon.py delete mode 100644 examples/scripts/backtrace create mode 100644 examples/scripts/debugging/linux/backtrace create mode 100644 examples/scripts/debugging/solaris/README create mode 100644 examples/scripts/debugging/solaris/solaris-oops.sh delete mode 100755 examples/scripts/perl/modify_samba_config.pl delete mode 100755 examples/scripts/perl/smbaddprinter.pl delete mode 100755 examples/scripts/perl/smbdelprinter.pl create mode 100755 examples/scripts/printing/cups/smbaddprinter.pl create mode 100755 examples/scripts/printing/cups/smbdelprinter.pl delete mode 100644 examples/scripts/python/SambaConfig.py delete mode 100644 examples/scripts/python/SambaParm.py delete mode 100755 examples/scripts/python/generate_parm_table.py delete mode 100755 examples/scripts/python/modify_samba_config.py delete mode 100644 examples/scripts/python/smbparm.py create mode 100755 examples/scripts/shares/perl/modify_samba_config.pl create mode 100644 examples/scripts/shares/python/SambaConfig.py create mode 100644 examples/scripts/shares/python/SambaParm.py create mode 100755 examples/scripts/shares/python/generate_parm_table.py create mode 100755 examples/scripts/shares/python/modify_samba_config.py create mode 100644 examples/scripts/shares/python/smbparm.py delete mode 100644 examples/svr4-startup/README delete mode 100755 examples/svr4-startup/samba.server (limited to 'examples') diff --git a/examples/debugging/README b/examples/debugging/README deleted file mode 100644 index 9e336805e5..0000000000 --- a/examples/debugging/README +++ /dev/null @@ -1,28 +0,0 @@ -Last update: John H Terpstra - June 27, 2005 - -Subject: This directory will contain debugging tools and tips. - -Notes: Identification and confirmation of some bugs can be difficult. - When such bugs are encountered it is necessary to provide as - sufficient detailed debugging information to assist the developer - both by providing incontrivertable proof of the problem, but also - precise information regarding the values of variables being processed - at the time the problem strikes. - - This directory is the ideal place to locate useful hints, tips and - methods that will help Samba users to provide the information that - developers need. - -============================ Solaris Method A ============================== -File: solaris-oops.sh -Contributor: David Collier-Brown -Date: June 27, 2005 -Method and Use: -To the global stanza of smb.conf add: - panic action = /usr/local/bin/solaris-oops.sh %d - -When the panic action is initiated a voluntary core dump file will be placed -in /var/tmp. Use this method with "log level = 10" and an smbd binary that -has been built with the '-g' option. -============================================================================ - diff --git a/examples/debugging/solaris-oops.sh b/examples/debugging/solaris-oops.sh deleted file mode 100644 index 82c49efdf6..0000000000 --- a/examples/debugging/solaris-oops.sh +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/sh -# -# solaris_panic_action -- capture supporting information after a failure -# -ProgName=`basename $0` -LOGDIR=/usr/local/samba/var - -main() { - pid=$1 - - if [ $# -lt 1 ]; then - say "$ProgName error: you must supply a pid" - say "Usage: $0 pid" - exit 1 - fi - cat >>$LOGDIR/log.solaris_panic_action <&2 -} - -main "$@" diff --git a/examples/genlogon/genlogon.pl b/examples/genlogon/genlogon.pl deleted file mode 100644 index 8ebf392141..0000000000 --- a/examples/genlogon/genlogon.pl +++ /dev/null @@ -1,71 +0,0 @@ -#!/usr/bin/perl -# -# genlogon.pl -# -# Perl script to generate user logon scripts on the fly, when users -# connect from a Windows client. This script should be called from smb.conf -# with the %U, %G and %L parameters. I.e: -# -# root preexec = genlogon.pl %U %G %L -# -# The script generated will perform -# the following: -# -# 1. Log the user connection to /var/log/samba/netlogon.log -# 2. Set the PC's time to the Linux server time (which is maintained -# daily to the National Institute of Standard's Atomic clock on the -# internet. -# 3. Connect the user's home drive to H: (H for Home). -# 4. Connect common drives that everyone uses. -# 5. Connect group-specific drives for certain user groups. -# 6. Connect user-specific drives for certain users. -# 7. Connect network printers. - -# Log client connection -#($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); -($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); -open LOG, ">>/var/log/samba/netlogon.log"; -print LOG "$mon/$mday/$year $hour:$min:$sec - User $ARGV[0] logged into $ARGV[1]\n"; -close LOG; - -# Start generating logon script -open LOGON, ">/shared/netlogon/$ARGV[0].bat"; -print LOGON "\@ECHO OFF\r\n"; - -# Connect shares just use by Software Development group -if ($ARGV[1] eq "SOFTDEV" || $ARGV[0] eq "softdev") -{ - print LOGON "NET USE M: \\\\$ARGV[2]\\SOURCE\r\n"; -} - -# Connect shares just use by Technical Support staff -if ($ARGV[1] eq "SUPPORT" || $ARGV[0] eq "support") -{ - print LOGON "NET USE S: \\\\$ARGV[2]\\SUPPORT\r\n"; -} - -# Connect shares just used by Administration staff -If ($ARGV[1] eq "ADMIN" || $ARGV[0] eq "admin") -{ - print LOGON "NET USE L: \\\\$ARGV[2]\\ADMIN\r\n"; - print LOGON "NET USE K: \\\\$ARGV[2]\\MKTING\r\n"; -} - -# Now connect Printers. We handle just two or three users a little -# differently, because they are the exceptions that have desktop -# printers on LPT1: - all other user's go to the LaserJet on the -# server. -if ($ARGV[0] eq 'jim' - || $ARGV[0] eq 'yvonne') -{ - print LOGON "NET UsE LPT2: \\\\$ARGV[2]\\LJET3\r\n"; - print LOGON "NET USE LPT3: \\\\$ARGV[2]\\FAXQ\r\n"; -} -else -{ - print LOGON "NET USE LPT1: \\\\$ARGV[2]\\LJET3\r\n"; - print LOGON "NET USE LPT3: \\\\$ARGV[2]\\FAXQ\r\n"; -} - -# All done! Close the output file. -close LOGON; diff --git a/examples/logon/genlogon/genlogon.pl b/examples/logon/genlogon/genlogon.pl new file mode 100644 index 0000000000..8ebf392141 --- /dev/null +++ b/examples/logon/genlogon/genlogon.pl @@ -0,0 +1,71 @@ +#!/usr/bin/perl +# +# genlogon.pl +# +# Perl script to generate user logon scripts on the fly, when users +# connect from a Windows client. This script should be called from smb.conf +# with the %U, %G and %L parameters. I.e: +# +# root preexec = genlogon.pl %U %G %L +# +# The script generated will perform +# the following: +# +# 1. Log the user connection to /var/log/samba/netlogon.log +# 2. Set the PC's time to the Linux server time (which is maintained +# daily to the National Institute of Standard's Atomic clock on the +# internet. +# 3. Connect the user's home drive to H: (H for Home). +# 4. Connect common drives that everyone uses. +# 5. Connect group-specific drives for certain user groups. +# 6. Connect user-specific drives for certain users. +# 7. Connect network printers. + +# Log client connection +#($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); +($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); +open LOG, ">>/var/log/samba/netlogon.log"; +print LOG "$mon/$mday/$year $hour:$min:$sec - User $ARGV[0] logged into $ARGV[1]\n"; +close LOG; + +# Start generating logon script +open LOGON, ">/shared/netlogon/$ARGV[0].bat"; +print LOGON "\@ECHO OFF\r\n"; + +# Connect shares just use by Software Development group +if ($ARGV[1] eq "SOFTDEV" || $ARGV[0] eq "softdev") +{ + print LOGON "NET USE M: \\\\$ARGV[2]\\SOURCE\r\n"; +} + +# Connect shares just use by Technical Support staff +if ($ARGV[1] eq "SUPPORT" || $ARGV[0] eq "support") +{ + print LOGON "NET USE S: \\\\$ARGV[2]\\SUPPORT\r\n"; +} + +# Connect shares just used by Administration staff +If ($ARGV[1] eq "ADMIN" || $ARGV[0] eq "admin") +{ + print LOGON "NET USE L: \\\\$ARGV[2]\\ADMIN\r\n"; + print LOGON "NET USE K: \\\\$ARGV[2]\\MKTING\r\n"; +} + +# Now connect Printers. We handle just two or three users a little +# differently, because they are the exceptions that have desktop +# printers on LPT1: - all other user's go to the LaserJet on the +# server. +if ($ARGV[0] eq 'jim' + || $ARGV[0] eq 'yvonne') +{ + print LOGON "NET UsE LPT2: \\\\$ARGV[2]\\LJET3\r\n"; + print LOGON "NET USE LPT3: \\\\$ARGV[2]\\FAXQ\r\n"; +} +else +{ + print LOGON "NET USE LPT1: \\\\$ARGV[2]\\LJET3\r\n"; + print LOGON "NET USE LPT3: \\\\$ARGV[2]\\FAXQ\r\n"; +} + +# All done! Close the output file. +close LOGON; diff --git a/examples/logon/mklogon/mklogon.conf b/examples/logon/mklogon/mklogon.conf new file mode 100644 index 0000000000..1f1faa77e3 --- /dev/null +++ b/examples/logon/mklogon/mklogon.conf @@ -0,0 +1,77 @@ +# Mapping should be kept in the form +# username(USER) or groupname(WEBUSERS) = driveletter (W:), samba share name (WEB) +# ie. user = W:,WEB or webusers = W:,WEB +# Problem found when testing, if there is a duplicate entry only the last one is used, +# not the first or both, another problem is that when testing I found a bug in Config::Simple, if you have a tab +# infront of your # on a comment it breaks ... +# logging = yes # Should Logging be enabled (YES,ON,1 or NO,OFF,0)(if not specified defaults to no) +# logdir = "/root/perl" # What is the base directory the logs should be stored. +# logfile = "userlogs.txt" # What should the file be named. +# logtype = file (default) # file will log to the file specified, syslog is well... the system logs ;) + +[global] +logging = yes +logdir = "/home/samba/netlogon" +logfile = "UserLogs.txt" +logtype = system +mkprofile = 1 +timesync = yes +sambaconf = "/etc/samba/smb.conf" + +# Change and uncomment the below value to force the servername, some clients ocassionally +# have trouble picking up the right servername so it may need to be set. It CANNOT be left blank AND uncommented. +# servername = staticservername + +[common] +public = P:, public +home = H:, /home + +[groupmap] +admin = Y:, UTILS +adm = R:, NETLOGON + +[usermap] +user1 = G:, GHOST +beanbags = Q:, STAR +avinst = P:\\vexira\\vexprof.bat + +# Here is where things get confusing, you can assign a computer, or make a group of computers. +# The same context will go for ip address's as well. +# Use the following examples for help. +# To define a single computer to do commands +# mymachinename = command1, command2 +# To define a group of computers to do commands +# mymachinegroup = machinename1, machinename2 +# [preformcommands] +# mymachinegroup = command1,command2 + +[machines] +#emints 1 is jf +emints1 = school-w88zfod9, school-o8axvv6t, school-mmtudgbo, school-dpokmajd, school-m84hx4iw, school-74548k1j, school-vou4gdap, school-qfuw5uho +#emints 2 is kh +emints2 = school-w7loulcx, school-2tbh64eu, school-uunqieuz, school-pow35do4, school-x0v0cbiz, school-zu5qyjhw, school-l4q4j32o + +[ip] +ipgroup1 = 10.5.1.1 - 10.5.1.10, 10.1.1.255/24 +ipgroup2 = 10.1.1.1 + +# This is the section where you can specify things according to the operating system of the client. +# The clients OS -- Windows 95/98/ME (Win95), Windows NT (WinNT), +# Windows 2000 (Win2K), Windows XP (WinXP), and Windows 2003 +# (Win2K3). Anything else will be known as ``UNKNOWN'' +# That snippet is directly from man smb.conf. +# + +[os] +Win95 = REM your computer is windows 9x based +WinNT = +Win2K = +WinXP = +Win2K3 = +UNKNOWN = + +[preformcommands] +emints1 = START \\\\JF-TEACHER\\Brother, START \\\\JF-TEACHER\\Canon, REGEDIT /S P:\\SETHOME-JF.REG, your in emints 1 +emints2 = START \\\\s0034292474\\Brother, START \\\\s0034292474\\Canon, REGEDIT /S P:\\SETHOME-KH.REG +ipgroup1 = echo your in the ip group +ipgroup2 = echo your in the ip group 2, start command.com diff --git a/examples/logon/mklogon/mklogon.pl b/examples/logon/mklogon/mklogon.pl new file mode 100644 index 0000000000..88ee97c979 --- /dev/null +++ b/examples/logon/mklogon/mklogon.pl @@ -0,0 +1,383 @@ +#!/usr/bin/perl -w + +# 05/01/2005 - 18:07:10 +# +# mklogon.pl - Login Script Generator +# Copyright (C) 2005 Ricky Nance +# ricky.nance@gmail.com +# http://www.weaubleau.k12.mo.us/~rnance/samba/mklogon.txt +# +# 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 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# + +# Version: 1.1 Beta +# Revised: 06/28/2005 + +# Comments... +# Working on logging to the system logs, Logs user activity, but not errors yet. + +use strict; +use Getopt::Long; + +eval { require Config::Simple; }; +if ($@) { + print("\n"); + print( "It appears as though you don't have the Config Simple perl module installed.\n" ); + print("The package is typically called 'Config::Simple' \n"); + print("and it needs to be installed, before you can use this utility\n"); + print("Most PERL installations will allow you to use a command like\n"); + print("\ncpan -i Config::Simple\n"); + print("from the command line while logged in as the root user.\n"); + print("\n"); + exit(1); +} + +# use Data::Dumper; #Used for debugging purposes + +# This variable should point to the external conf file, personally I would set +# it to /etc/samba/mklogon.conf +my $configfile; + +foreach my $dir ( ( '/etc', '/etc/samba', '/usr/local/samba/lib' ) ) { + if ( -e "$dir/mklogon.conf" ) { + $configfile = "$dir/mklogon.conf"; + last; + } +} + +# This section will come directly from the samba server. Basically it just makes the script easier to read. +my $getopts = GetOptions( + 'u|username=s' => \my $user, + 'm|machine=s' => \my $machine, + 's|servername=s' => \my $server, + 'o|ostype=s' => \my $os, + 'i|ip=s' => \my $ip, + 'd|date=s' => \my $smbdate, + 'h|help|?' => \my $help +); + +if ($help) { + help(); + exit(0); +} + +# We want the program to error out if its missing an argument. +if ( !defined($user) ) { error("username"); } +if ( !defined($machine) ) { error("machine name") } +if ( !defined($server) ) { error("server name") } +if ( !defined($os) ) { error("operating system") } +if ( !defined($ip) ) { error("ip address") } +if ( !defined($smbdate) ) { error("date") } + +# This section will be read from the external config file +my $cfg = new Config::Simple($configfile) or die "Could not find $configfile"; + +# Read this part from the samba config +my ( $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst ) = localtime(time); +my $sambaconf = $cfg->param("global.sambaconf") or die "Couldn't find your samba config! \n"; +my $smbcfg = new Config::Simple( filename => $sambaconf, syntax => "ini" ); +my $smbprof = $smbcfg->param("profiles.path"); +my $smbnetlogdir = $smbcfg->param("netlogon.path"); +my $logging = lc( $cfg->param("global.logging") ); +my $mkprofile = lc( $cfg->param("global.mkprofile") ); +my $logdir = $cfg->param("global.logdir"); +my $logfile = $cfg->param("global.logfile"); +my $logs = "$logdir\/$logfile"; +my $logtype = $cfg->param("global.logtype"); +my $usermap = "usermap.$user"; +my $osmap = "os.$os"; +my @ostype = $cfg->param($osmap); +my @username = $cfg->param($usermap); +my $compname = $cfg->param( -block => "machines" ); +my $ipname = $cfg->param( -block => "ip" ); +my $timesync = $cfg->param("global.timesync"); +my $altserver = $cfg->param("global.servername"); +if ( defined($altserver) ) { $server = $altserver; } +$server = uc($server); + +# Lets start logging stuff if it is turned on in the config +if ( $logging =~ m/on|yes|1/i ) { + if ($logtype =~ m/file/i) { + print "----- Logging is turned on in the config. -----\n"; + print "----- Location of the logfile is \"$logs\" -----\n"; + open LOG, ">>$logs"; + printf LOG "Date: $smbdate Time: "; + printf LOG '%02d', $hour; + print LOG ":"; + printf LOG '%02d', $min; + print LOG "."; + printf LOG '%02d', $sec; + print LOG " -- User: $user - Machine: $machine - IP: $ip -- \n"; + close(LOG); + } elsif ($logtype =~ m/syslog|system/i){ + use Sys::Syslog; + my $alert = "User: $user Logged into $machine ($ip) at $hour:$min.$sec on $smbdate."; + openlog($0, 'cons', 'user'); + syslog('alert', $alert); + closelog(); + + } +} else { + print "----- Logging is turned off in the config. -----\n"; +} + +# If the user wants to make profiles with this script lets go +if ( defined($smbprof) ) { + if ( $mkprofile =~ m/on|yes|1/i ) { + print "----- Automatic making of user profiles is turned on in the config. ----- \n"; + ( my $login, my $pass, my $uid, my $gid ) = getpwnam($user) + or die "$user not in passwd file \n"; + $smbprof =~ s/\%U/$user/g; + my $dir2 = "$smbprof\/$user"; + print "$smbprof \n"; + print "$dir2 \n"; + if ( !-e $dir2 ) { + print "Creating " . $user . "'s profile \n"; + mkdir $smbprof; + mkdir $dir2; + chomp($user); + chown $uid, $gid, $smbprof; + chown $uid, $gid, $dir2; + } else { + print $user . "'s profile already exists \n"; + } + } else { + print "----- Automatic making of user profiles is turned off in the config. ----- \n"; + } +} + +# Lets start making the batch files. +open LOGON, ">$smbnetlogdir\/$user.bat" or die "Unable to create userfile $smbnetlogdir\/$user.bat"; +print LOGON "\@ECHO OFF \r\n"; + +if ( $timesync =~ m/on|yes|1/i ) { + print LOGON "NET TIME /SET /YES \\\\$server \r\n"; +} else { + print "----- Time syncing to the client is turned off in the config. -----\n"; +} + +# Mapping from the common section +my $common = $cfg->param( -block => "common" ); +for my $key ( keys %$common ) { + drive_map( @{ $common->{$key} } ); +} + +# Map shares on a per user basis. +drive_map(@username); + +# Map shares based on the Operating System. +drive_map(@ostype); + +# Map shares only if they are in a group +# This line checks against the unix "groups" command, to see the secondary groups of a user. +my @usergroups = split( /\s/, do { open my $groups, "-|", groups => $user; <$groups> } ); +foreach (@usergroups) { + my $groupmap = "groupmap.$_"; + my @groupname = $cfg->param($groupmap); + drive_map(@groupname); +} + +#Here is where we check the machine name against the config... +for my $key ( keys %$compname ) { + my $test = $compname->{$key}; + if ( ref $test eq 'ARRAY' ) { + foreach (@$test) { + if ( $_ eq $machine ) { + my $preformit = $cfg->param("preformcommands.$key"); + if ( defined($preformit) ) { + if ( ref $preformit ) { + foreach (@$preformit) { print LOGON "$_ \r\n"; } + } else { + print LOGON "$preformit \r\n"; + } + } + } + } + } + elsif ( $test eq $machine ) { + my $preformit = $cfg->param("preformcommands.$key"); + if ( defined($preformit) ) { + if ( ref $preformit ) { + foreach (@$preformit) { print LOGON "$_ \r\n"; } + } else { + print LOGON "$preformit \r\n"; + } + } + } +} + +# Here is where we test the ip address against the client to see if they have "Special Mapping" +my $val; +for my $key ( sort keys %$ipname ) { + if ( ref $ipname->{$key} eq 'ARRAY' ) { + foreach ( @{ $ipname->{$key} } ) { + getipval( $_, $key ); + } + } else { + getipval( $ipname->{$key}, $key ); + } +} + +sub getipval { + my ( $range, $rangename ) = @_; + if ( parse( $ip, ipmap($range) ) ) { + if ( $val eq 'true' ) { + my $preformit = $cfg->param("preformcommands.$rangename"); + if ( defined($preformit) ) { + if ( ref $preformit ) { + foreach (@$preformit) { print LOGON "$_ \r\n"; } + } else { + print LOGON "$preformit \r\n"; + } + } + } elsif ( $val eq 'false' ) { + } + } else { + } +} + +sub ipmap { + my $pattern = shift; + my ( $iprange, $iprange2, $ipmask ); + if ( $pattern =~ m/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\/(\d{1,2})$/ ) { + # 1.1.1.1/3 notation + $iprange = pack( "U4", $1, $2, $3, $4 ); + $ipmask = pack( "U4", 0, 0, 0, 0 ); + my $numbits = $5; + for ( my $i = 0 ; $i < $numbits ; $i++ ) { + vec( $ipmask, int( $i / 8 ) * 8 + ( 8 - ( $i % 8 ) ) - 1, 1 ) = 1; + } + $iprange &= "$ipmask"; + } elsif ( $pattern =~ m/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\/(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/ ) { + # 1.1.1.1/255.255.255.255 notation + $iprange = pack( "U4", $1, $2, $3, $4 ); + $ipmask = pack( "U4", $5, $6, $7, $8 ); + $iprange &= "$ipmask"; + } elsif ( $pattern =~ m/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/ ) { + # 1.1.1.1 notation + $iprange = pack( "U4", $1, $2, $3, $4 ); + $ipmask = pack( "U4", 255, 255, 255, 255 ); + } elsif ( $pattern =~ m/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\s*\-\s*(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/ ) { + # 1.1.1.1 - 2.2.2.2 notation + $iprange = pack( "U4", $1, $2, $3, $4 ); + $iprange2 = pack( "U4", $5, $6, $7, $8 ); + $ipmask = pack( "U4", 255, 255, 255, 255 ); + } else { + return; + } + return $iprange, $ipmask, $iprange2; +} + +sub parse { + my ( $origip, $ipbase, $ipmask, $iprange2 ) = @_; + $origip =~ m/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/; + $origip = pack( "U4", $1, $2, $3, $4 ); + if ( defined($iprange2) ) { + if ( $ipbase le $origip && $origip le $iprange2 ) { + return $val = 'true'; + } else { + return $val = 'false'; + } + } elsif ( ( "$origip" & "$ipmask" ) eq $ipbase ) { + return $val = 'true'; + } else { + return $val = 'false'; + } +} + +# This sub will distinguish the drive mappings +sub drive_map { + my @data = @_; + for ( my $i = 0 ; $i < scalar(@data) ; ) { + if ( $data[$i] =~ m/^[a-z]\:$/i ) { + my $driveletter = $data[$i]; + $i++; + my $sharename = $data[$i]; + $i++; + if ( $sharename eq '/home' ) { + print LOGON uc("NET USE $driveletter $sharename \/Y \r\n"); + } else { + print LOGON + uc("NET USE $driveletter \\\\$server\\$sharename \/Y \r\n"); + } + } else { + print LOGON uc("$data[$i] \r\n"); + $i++; + } + } +} + +close(LOGON); + +sub error { + my $var = shift(@_); + help(); + print "\n\tCritical!!! \n\n\tNo $var specified\n\n\tYou must specify a $var.\n\n"; + exit(0); +} + +sub help { + + print << "EOF" ; + + Usage: $0 [options] + + Options: + + -h,--help This help screen. + + -u,--username The name of the user from the samba server. + + -m,--machinename The name of the client connecting to the server. + + -s,--server The name of the server this script is running in. + + -o,--os The clients OS -- Windows 95/98/ME (Win95), Windows NT (WinNT), + Windows 2000 (Win2K), Windows XP (WinXP), and Windows 2003 + (Win2K3). Anything else will be known as ``UNKNOWN'' + That snippet is directly from man smb.conf. + + -i,--ip The clients IP address. + + -d,--date Time and Date returned from the samba server. + + + + --IMPORTANT-- + + + All options MUST be specified. + + The mklogon.conf file MUST be located in /etc, /etc/samba, or + /usr/local/samba/lib. + + To use this file from the command line: + $0 -u User -m machine -s servername -o ostype -i X.X.X.X -d MM/DD/YY + + To use this file from the samba server add these lines to your /etc/samba/smb.conf: + + + This line goes in the [global] section + login script = %U.bat + + This line should be at the end of the [netlogon] section. + root preexec = /path/to/mklogon.pl -u %U -m %m -s %L -o %a -i %I -d %t + + +EOF + + print "\n\n"; + +} diff --git a/examples/logon/ntlogon/README b/examples/logon/ntlogon/README new file mode 100644 index 0000000000..e33c565d71 --- /dev/null +++ b/examples/logon/ntlogon/README @@ -0,0 +1,160 @@ +ntlogon.py v0.8b Copyright 2002 by Timothy (rhacer) Grant +This programme is released under the terms of the GNU Public License +This programme has NO WARRANTY of any kind, use at your own risk. + +=================== +CHANGES SINCE v0.7b +=================== +included patch that made machine name %m a macro substitution value. +Thanks to: Nick Lopez + +================== +CHANGES SINCE v0.6 +================== +PLEASE NOT THAT I AM CONSIDERING THIS A BETA UNTIL I GET SOME FEEDBACK +FROM USERS ON WHETHER THE MACRO FEATURE WORKS FOR THEM. + +added the ability to define substitution macros: see the useage section + +removed the large docstring from the file and moved the information to +the USEAGE section of this file + +cleaned up the code and made more flexible + +improved the code comments + +================== +CHANGES SINCE v0.5 +================== +added a -v --version switch + +added a --pause switch which will put a pause statement between each +non-blank line of the script. + +=============== +A PERSONAL NOTE +=============== +When I originally posted v0.5 on Freshmeat, I really expected *some* +feedback. To date this little script has been downloaded over 700 times, but +absolutely nobody has sent me an e-mail to tell me if it is useful, or if +it is absolutely the stupidest waste of bandwidth they have ever seen. +I'd really love to know if even one person other than me and the other techs +here at Avalon have found it useful. + +Thanks. + rhacer (rhacer@craigelachie.org) + +September 27, 2000 +Thanks to those that did respond to my plea! I'd still love to hear from +any other users! + +============ +INTRODUCTION +============ +As my experience with Linux and Samba increased, I had no trouble whipping up +a custom Perl, Python or Bash script to create Samba Logon Scripts, but I +noticed that I changed things from place to place, and that my users had *no* +chance of ever figuring out how to modify those scripts themselves. + +In an attempt to create a company wide standard that both my co-workers and my +customers could *easily* modify I hit upon the scheme I used here. + +I settled on an INI file feel, because most who have experience with Win boxes +have some concept of INI files. + +============ +INSTALLATION +============ +The distribution archive contains three files: + +README This file +ntlogon.py The actual Python script (place in /usr/local/samba/bin) +ntlogon.conf A sample configuration file (place in /etc) + +This script was created using Python v1.5.2, and I believe it uses only +standard libraries. + +Your smb.conf file needs to contain a netlogon section similar to the +following (These settings *are not* normal on a RH box. These settings +are all based on the excellent book that I learned Samba from: Samba +Integrating Unix and Windows by John D. Blair. It is somewhat out of +date now, but that's the history of the strange file locations): + +[netlogon] + path = /usr/local/samba/netlogon + writeable = no + guest ok = no + root preexec = /usr/local/samba/bin/ntlogon --user=%U --os=%m + root postexec = rm /usr/local/samba/netlogon/%U.bat + +====== +USEAGE +====== +PLEASE SEE NTLOGON.CONF FOR A DETAILED CONFIGURATION EXAMPLE + +This programme will build a Windows NT logon script for users connecting +to a Samba server. Samba macros that are curently understood: + + %U user name + %G group name + %a machine architecture + %m machine netbios name + +This programme reads a configuration that looks strikingly similar to both +the Samba configuration file, and a DOS "boot menu" AUTOEXEC.BAT file. + +The default file name is /etc/ntlogon.conf (though I really think it ought +to be called ntlogon.batch!) You may change the filename by using the -f +or --templatefile startup option. + +The default netlogon directory is /usr/local/samba/netlogon though this +can be changed with the -d or --dir startup option. + +The default batch file name generated is username.bat if no username is +specified the default value is logon.bat (e.g., if --user=fred is specified +on the command line then the logon script generated will be stored in +fred.bat) + +Use the --debug option to print the logon script to screen instead of the +output file + +Use the --pause option to place a pause statement between each line of the +script to assist in debugging a logon script. + +The file is divided into sections that have headers in square brackets + +[Global] +[User-username] +[Group-groupname] +[OS-osname] + +The file may also contain user defined substitution macros. They are +defined by placing the macro name on the left side of an equal sign, +and the substitution text on the right side of the equal sign. They +are also case sensitive: + +MAINDRIVE = G: +USERDRIVE = U: +SERVERNAME = myservername + +They are referenced by prepending a "%" sign to the variable name: + +NET USE %MAINDRIVE \\\\servername\\mainshare /YES +NET USE %USERDRIVE \\\\%SERVERNAME\\usershare /YES + +============== +SPECIAL THANKS +============== +Nick Lopez for the net bios name patch. + +=================== +CONTACT INFORMATION +=================== +Author : Timothy (rhacer) Grant + +I can be reached at tjg@craigelachie.org +ntlogon website www.craigelachie.org/rhacer/ntlogon + +Please feel free to contact me with any suggestions, improvements, bugs you +might find. + diff --git a/examples/logon/ntlogon/ntlogon.conf b/examples/logon/ntlogon/ntlogon.conf new file mode 100644 index 0000000000..e1573a6118 --- /dev/null +++ b/examples/logon/ntlogon/ntlogon.conf @@ -0,0 +1,44 @@ +# Everything in the Global section applies to all users logging on to the +# network +[Global] + +#Some substitution macro definitions +MAINDRIVE = G: +USERDRIVE = U: +SERVERNAME = myservername + +@ECHO "Welcome to our network!!!" +NET TIME \\servername /SET /YES +NET USE %MAINDRIVE \\%SERVERNAME\globalshare /YES + +# Map the private user area in the global section so we don't have to +# create individual user entries for each user! +NET USE %USERDRIVE \\servername\%U /YES + +# Group entries, User entries and OS entries each start with the +# keyword followed by a dash followed by--appropriately enough the Group +# name, the User name, or the OS name. +[Group-admin] +@ECHO "Welcome administrators!" +NET USE G: \\servername\adminshare1 /YES +NET USE I: \\servername\adminshare2 /YES + +[Group-peons] +@ECHO "Be grateful we let you use computers!" +NET USE G: \\servername\peonshare1 /YES + +[Group-hackers] +@ECHO "What can I do for you today great one?" +NET USE G: \\servername\hackershare1 /YES +NET USE I: \\servername\adminshare2 /YES + +[User-fred] +@ECHO "Hello there Fred!" +NET USE F: \\servername\fredsspecialshare /YES + +[OS-WfWg] +@ECHO "Time to upgrade isn't it?" + +# End configuration file + +X = Will this break? diff --git a/examples/logon/ntlogon/ntlogon.py b/examples/logon/ntlogon/ntlogon.py new file mode 100755 index 0000000000..ba46ba8ffc --- /dev/null +++ b/examples/logon/ntlogon/ntlogon.py @@ -0,0 +1,376 @@ +#!/usr/bin/env python +""" +ntlogon.py written by Timothy (rhacer) Grant + +Copyright 1999 - 2002 by Timothy Grant + +is distributed under the terms of the GNU Public License. + +The format for the configuration file is as follows: + +While there is some room for confusion, we attempt to process things in +order of specificity: Global first, Group second, User third, OS Type +forth. This order can be debated forever, but it seems to make the most +sense. + +# Everything in the Global section applies to all users logging on to the +# network +[Global] +@ECHO "Welcome to our network!!!" +NET TIME \\\\servername /SET /YES +NET USE F: \\\\servername\\globalshare /YES + +# Map the private user area in the global section so we don't have to +# create individual user entries for each user! +NET USE U: \\\\servername\\%U /YES + +# Group entries, User entries and OS entries each start with the +# keyword followed by a dash followed by--appropriately enough the Group +# name, the User name, or the OS name. +[Group-admin] +@ECHO "Welcome administrators!" +NET USE G: \\\\servername\\adminshare1 /YES +NET USE I: \\\\servername\\adminshare2 /YES + +[Group-peons] +@ECHO "Be grateful we let you use computers!" +NET USE G: \\\\servername\\peonshare1 /YES + +[Group-hackers] +@ECHO "What can I do for you today great one?" +NET USE G: \\\\servername\\hackershare1 /YES +NET USE I: \\\\servername\\adminshare2 /YES + +[User-fred] +@ECHO "Hello there Fred!" +NET USE F: \\\\servername\\fredsspecialshare /YES + +[OS-WfWg] +@ECHO "Time to upgrade it?" + +# End configuration file + +usage: ntlogon [-g | --group=groupname] + [-u | --user=username] + [-o | --os=osname] + [-m | --machine=netbiosname] + [-f | --templatefile=filename] + [-d | --dir=netlogon directory] + [-v | --version] + [-h | --help] + [--pause] + [--debug] +""" +# +#" This quote mark is an artifact of the inability of my editor to +# correctly colour code anything after the triple-quoted docstring. +# if your editor does not have this flaw, feel free to remove it. + + +import sys +import getopt +import re +import string +import os + +version = "ntlogon.py v0.8" + +def buildScript(buf, sections, group, user, ostype, machine, debug, pause): + """ + buildScript() Takes the contents of the template file and builds + a DOS batch file to be executed as an NT logon script. It does this + by determining which sections of the configuration file should be included + and creating a list object that contains each line contained in each + included section. The list object is then returned to the calling + routine. + + All comments (#) are removed. A REM is inserted to show + which section of the configuration file each line comes from. + We leave blanklines as they are sometimes useful for debugging + + We also replace all of the Samba macros (e.g., %U, %G, %a, %m) with their + expanded versions which have been passed to us by smbd + """ + hdrstring = '' + script = [] + + # + # These are the Samba macros that we currently know about. + # any user defined macros will also be added to this dictionary. + # We do not store the % sign as part of the macro name. + # The replace routine will prepend the % sign to all possible + # replacements. + # + macros = { + 'U': user, + 'G': group, + 'a': ostype, + 'm': machine + } + + # + # Process each section defined in the list sections + # + for s in sections: + # print 'searching for: ' + s + + idx = 0 + + while idx < len(buf): + ln = buf[idx] + + # + # We need to set up a regex for each possible section we + # know about. This is slightly complicated due to the fact + # that section headers contain user defined text. + # + if s == 'Global': + hdrstring = '\[ *' + s + ' *\]' + elif s == 'Group': + hdrstring = '\[ *' + s + ' *- *' + group + ' *\]' + elif s == 'User': + hdrstring = '\[ *' + s + ' *- *' + user + ' *\]' + elif s == 'OS': + hdrstring = '\[ *' + s + ' *- *' + ostype + ' *\]' + elif s == 'Machine': + hdrstring = '\[ *' + s + ' *- *' + machine + ' *\]' + + # + # See if we have found a section header + # + if re.search(r'(?i)' + hdrstring, ln): + idx = idx + 1 # increment the counter to move to the next + # line. + + x = re.match(r'([^#\r\n]*)', ln) # Determine the section + # name and strip out CR/LF + # and comment information + + if debug: + print 'rem ' + x.group(1) + ' commands' + else: + # create the rem at the beginning of each section of the + # logon script. + script.append('rem ' + x.group(1) + ' commands') + + # + # process each line until we have found another section + # header + # + while not re.search(r'.*\[.*\].*', buf[idx]): + + # + # strip comments and line endings + # + x = re.match(r'([^#\r\n]*)', buf[idx]) + + if string.strip(x.group(1)) != '' : + # if there is still content after stripping comments and + # line endings then this is a line to process + + line = x.group(1) + + # + # Check to see if this is a macro definition line + # + vardef = re.match(r'(.*)=(.*)', line) + + if vardef: + varname = string.strip(vardef.group(1)) # Strip leading and + varsub = string.strip(vardef.group(2)) # and trailing spaces + + if varname == '': + print "Error: No substition name specified line: %d" % idx + sys.exit(1) + + if varsub == '': + print "Error: No substitution text provided line: %d" % idx + sys.exit(1) + + if macros.has_key(varname): + print "Warning: macro %s redefined line: %d" % (varname, idx) + + macros[varname] = varsub + idx = idx + 1 + continue + + # + # Replace all the macros that we currently + # know about. + # + # Iterate over the dictionary that contains all known + # macro substitutions. + # + # We test for a macro name by prepending % to each dictionary + # key. + # + for varname in macros.keys(): + line = re.sub(r'%' + varname + r'(\W)', + macros[varname] + r'\1', line) + + if debug: + print line + if pause: + print 'pause' + else: + script.append(line) + + idx = idx + 1 + + if idx == len(buf): + break # if we have reached the end of the file + # stop processing. + + idx = idx + 1 # increment the line counter + + if debug: + print '' + else: + script.append('') + + return script + +# End buildScript() + +def run(): + """ + run() everything starts here. The main routine reads the command line + arguments, opens and reads the configuration file. + """ + configfile = '/etc/ntlogon.conf' # Default configuration file + group = '' # Default group + user = '' # Default user + ostype = '' # Default os + machine = '' # Default machine type + outfile = 'logon.bat' # Default batch file name + # this file name WILL take on the form + # username.bat if a username is specified + debug = 0 # Default debugging mode + pause = 0 # Default pause mode + outdir = '/usr/local/samba/netlogon/' # Default netlogon directory + + sections = ['Global', 'Machine', 'OS', 'Group', 'User'] # Currently supported + # configuration file + # sections + + options, args = getopt.getopt(sys.argv[1:], 'd:f:g:ho:u:m:v', + ['templatefile=', + 'group=', + 'help', + 'os=', + 'user=', + 'machine=', + 'dir=', + 'version', + 'pause', + 'debug']) + + # + # Process the command line arguments + # + for i in options: + # template file to process + if (i[0] == '-f') or (i[0] == '--templatefile'): + configfile = i[1] + # print 'configfile = ' + configfile + + # define the group to be used + elif (i[0] == '-g') or (i[0] == '--group'): + group = i[1] + # print 'group = ' + group + + # define the os type + elif (i[0] == '-o') or (i[0] == '--os'): + ostype = i[1] + # print 'os = ' + os + + # define the user + elif (i[0] == '-u') or (i[0] == '--user'): + user = i[1] + outfile = user + '.bat' # Setup the output file name + # print 'user = ' + user + + # define the machine + elif (i[0] == '-m') or (i[0] == '--machine'): + machine = i[1] + + # define the netlogon directory + elif (i[0] == '-d') or (i[0] == '--dir'): + outdir = i[1] + # print 'outdir = ' + outdir + + # if we are asked to turn on debug info, do so. + elif (i[0] == '--debug'): + debug = 1 + # print 'debug = ' + debug + + # if we are asked to turn on the automatic pause functionality, do so + elif (i[0] == '--pause'): + pause = 1 + # print 'pause = ' + pause + + # if we are asked for the version number, print it. + elif (i[0] == '-v') or (i[0] == '--version'): + print version + sys.exit(0) + + # if we are asked for help print the docstring. + elif (i[0] == '-h') or (i[0] == '--help'): + print __doc__ + sys.exit(0) + + # + # open the configuration file + # + try: + iFile = open(configfile, 'r') + except IOError: + print 'Unable to open configuration file: ' + configfile + sys.exit(1) + + + # + # open the output file + # + if not debug: + try: + oFile = open(outdir + outfile, 'w') + except IOError: + print 'Unable to open logon script file: ' + outdir + outfile + sys.exit(1) + + buf = iFile.readlines() # read in the entire configuration file + + # + # call the script building routine + # + script = buildScript(buf, sections, group, user, ostype, machine, debug, pause) + + # + # write out the script file + # + if not debug: + for ln in script: + oFile.write(ln + '\r\n') + if pause: + if string.strip(ln) != '': # Because whitespace + oFile.write('pause' + '\r\n') # is a useful tool, we + # don't put pauses after + # an empty line. + + +# End run() + +# +# immediate-mode commands, for drag-and-drop or execfile() execution +# +if __name__ == '__main__': + run() +else: + print "Module ntlogon.py imported." + print "To run, type: ntlogon.run()" + print "To reload after changes to the source, type: reload(ntlogon)" + +# +# End NTLogon.py +# diff --git a/examples/mklogon/mklogon.conf b/examples/mklogon/mklogon.conf deleted file mode 100644 index 1f1faa77e3..0000000000 --- a/examples/mklogon/mklogon.conf +++ /dev/null @@ -1,77 +0,0 @@ -# Mapping should be kept in the form -# username(USER) or groupname(WEBUSERS) = driveletter (W:), samba share name (WEB) -# ie. user = W:,WEB or webusers = W:,WEB -# Problem found when testing, if there is a duplicate entry only the last one is used, -# not the first or both, another problem is that when testing I found a bug in Config::Simple, if you have a tab -# infront of your # on a comment it breaks ... -# logging = yes # Should Logging be enabled (YES,ON,1 or NO,OFF,0)(if not specified defaults to no) -# logdir = "/root/perl" # What is the base directory the logs should be stored. -# logfile = "userlogs.txt" # What should the file be named. -# logtype = file (default) # file will log to the file specified, syslog is well... the system logs ;) - -[global] -logging = yes -logdir = "/home/samba/netlogon" -logfile = "UserLogs.txt" -logtype = system -mkprofile = 1 -timesync = yes -sambaconf = "/etc/samba/smb.conf" - -# Change and uncomment the below value to force the servername, some clients ocassionally -# have trouble picking up the right servername so it may need to be set. It CANNOT be left blank AND uncommented. -# servername = staticservername - -[common] -public = P:, public -home = H:, /home - -[groupmap] -admin = Y:, UTILS -adm = R:, NETLOGON - -[usermap] -user1 = G:, GHOST -beanbags = Q:, STAR -avinst = P:\\vexira\\vexprof.bat - -# Here is where things get confusing, you can assign a computer, or make a group of computers. -# The same context will go for ip address's as well. -# Use the following examples for help. -# To define a single computer to do commands -# mymachinename = command1, command2 -# To define a group of computers to do commands -# mymachinegroup = machinename1, machinename2 -# [preformcommands] -# mymachinegroup = command1,command2 - -[machines] -#emints 1 is jf -emints1 = school-w88zfod9, school-o8axvv6t, school-mmtudgbo, school-dpokmajd, school-m84hx4iw, school-74548k1j, school-vou4gdap, school-qfuw5uho -#emints 2 is kh -emints2 = school-w7loulcx, school-2tbh64eu, school-uunqieuz, school-pow35do4, school-x0v0cbiz, school-zu5qyjhw, school-l4q4j32o - -[ip] -ipgroup1 = 10.5.1.1 - 10.5.1.10, 10.1.1.255/24 -ipgroup2 = 10.1.1.1 - -# This is the section where you can specify things according to the operating system of the client. -# The clients OS -- Windows 95/98/ME (Win95), Windows NT (WinNT), -# Windows 2000 (Win2K), Windows XP (WinXP), and Windows 2003 -# (Win2K3). Anything else will be known as ``UNKNOWN'' -# That snippet is directly from man smb.conf. -# - -[os] -Win95 = REM your computer is windows 9x based -WinNT = -Win2K = -WinXP = -Win2K3 = -UNKNOWN = - -[preformcommands] -emints1 = START \\\\JF-TEACHER\\Brother, START \\\\JF-TEACHER\\Canon, REGEDIT /S P:\\SETHOME-JF.REG, your in emints 1 -emints2 = START \\\\s0034292474\\Brother, START \\\\s0034292474\\Canon, REGEDIT /S P:\\SETHOME-KH.REG -ipgroup1 = echo your in the ip group -ipgroup2 = echo your in the ip group 2, start command.com diff --git a/examples/mklogon/mklogon.pl b/examples/mklogon/mklogon.pl deleted file mode 100644 index 88ee97c979..0000000000 --- a/examples/mklogon/mklogon.pl +++ /dev/null @@ -1,383 +0,0 @@ -#!/usr/bin/perl -w - -# 05/01/2005 - 18:07:10 -# -# mklogon.pl - Login Script Generator -# Copyright (C) 2005 Ricky Nance -# ricky.nance@gmail.com -# http://www.weaubleau.k12.mo.us/~rnance/samba/mklogon.txt -# -# 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 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# - -# Version: 1.1 Beta -# Revised: 06/28/2005 - -# Comments... -# Working on logging to the system logs, Logs user activity, but not errors yet. - -use strict; -use Getopt::Long; - -eval { require Config::Simple; }; -if ($@) { - print("\n"); - print( "It appears as though you don't have the Config Simple perl module installed.\n" ); - print("The package is typically called 'Config::Simple' \n"); - print("and it needs to be installed, before you can use this utility\n"); - print("Most PERL installations will allow you to use a command like\n"); - print("\ncpan -i Config::Simple\n"); - print("from the command line while logged in as the root user.\n"); - print("\n"); - exit(1); -} - -# use Data::Dumper; #Used for debugging purposes - -# This variable should point to the external conf file, personally I would set -# it to /etc/samba/mklogon.conf -my $configfile; - -foreach my $dir ( ( '/etc', '/etc/samba', '/usr/local/samba/lib' ) ) { - if ( -e "$dir/mklogon.conf" ) { - $configfile = "$dir/mklogon.conf"; - last; - } -} - -# This section will come directly from the samba server. Basically it just makes the script easier to read. -my $getopts = GetOptions( - 'u|username=s' => \my $user, - 'm|machine=s' => \my $machine, - 's|servername=s' => \my $server, - 'o|ostype=s' => \my $os, - 'i|ip=s' => \my $ip, - 'd|date=s' => \my $smbdate, - 'h|help|?' => \my $help -); - -if ($help) { - help(); - exit(0); -} - -# We want the program to error out if its missing an argument. -if ( !defined($user) ) { error("username"); } -if ( !defined($machine) ) { error("machine name") } -if ( !defined($server) ) { error("server name") } -if ( !defined($os) ) { error("operating system") } -if ( !defined($ip) ) { error("ip address") } -if ( !defined($smbdate) ) { error("date") } - -# This section will be read from the external config file -my $cfg = new Config::Simple($configfile) or die "Could not find $configfile"; - -# Read this part from the samba config -my ( $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst ) = localtime(time); -my $sambaconf = $cfg->param("global.sambaconf") or die "Couldn't find your samba config! \n"; -my $smbcfg = new Config::Simple( filename => $sambaconf, syntax => "ini" ); -my $smbprof = $smbcfg->param("profiles.path"); -my $smbnetlogdir = $smbcfg->param("netlogon.path"); -my $logging = lc( $cfg->param("global.logging") ); -my $mkprofile = lc( $cfg->param("global.mkprofile") ); -my $logdir = $cfg->param("global.logdir"); -my $logfile = $cfg->param("global.logfile"); -my $logs = "$logdir\/$logfile"; -my $logtype = $cfg->param("global.logtype"); -my $usermap = "usermap.$user"; -my $osmap = "os.$os"; -my @ostype = $cfg->param($osmap); -my @username = $cfg->param($usermap); -my $compname = $cfg->param( -block => "machines" ); -my $ipname = $cfg->param( -block => "ip" ); -my $timesync = $cfg->param("global.timesync"); -my $altserver = $cfg->param("global.servername"); -if ( defined($altserver) ) { $server = $altserver; } -$server = uc($server); - -# Lets start logging stuff if it is turned on in the config -if ( $logging =~ m/on|yes|1/i ) { - if ($logtype =~ m/file/i) { - print "----- Logging is turned on in the config. -----\n"; - print "----- Location of the logfile is \"$logs\" -----\n"; - open LOG, ">>$logs"; - printf LOG "Date: $smbdate Time: "; - printf LOG '%02d', $hour; - print LOG ":"; - printf LOG '%02d', $min; - print LOG "."; - printf LOG '%02d', $sec; - print LOG " -- User: $user - Machine: $machine - IP: $ip -- \n"; - close(LOG); - } elsif ($logtype =~ m/syslog|system/i){ - use Sys::Syslog; - my $alert = "User: $user Logged into $machine ($ip) at $hour:$min.$sec on $smbdate."; - openlog($0, 'cons', 'user'); - syslog('alert', $alert); - closelog(); - - } -} else { - print "----- Logging is turned off in the config. -----\n"; -} - -# If the user wants to make profiles with this script lets go -if ( defined($smbprof) ) { - if ( $mkprofile =~ m/on|yes|1/i ) { - print "----- Automatic making of user profiles is turned on in the config. ----- \n"; - ( my $login, my $pass, my $uid, my $gid ) = getpwnam($user) - or die "$user not in passwd file \n"; - $smbprof =~ s/\%U/$user/g; - my $dir2 = "$smbprof\/$user"; - print "$smbprof \n"; - print "$dir2 \n"; - if ( !-e $dir2 ) { - print "Creating " . $user . "'s profile \n"; - mkdir $smbprof; - mkdir $dir2; - chomp($user); - chown $uid, $gid, $smbprof; - chown $uid, $gid, $dir2; - } else { - print $user . "'s profile already exists \n"; - } - } else { - print "----- Automatic making of user profiles is turned off in the config. ----- \n"; - } -} - -# Lets start making the batch files. -open LOGON, ">$smbnetlogdir\/$user.bat" or die "Unable to create userfile $smbnetlogdir\/$user.bat"; -print LOGON "\@ECHO OFF \r\n"; - -if ( $timesync =~ m/on|yes|1/i ) { - print LOGON "NET TIME /SET /YES \\\\$server \r\n"; -} else { - print "----- Time syncing to the client is turned off in the config. -----\n"; -} - -# Mapping from the common section -my $common = $cfg->param( -block => "common" ); -for my $key ( keys %$common ) { - drive_map( @{ $common->{$key} } ); -} - -# Map shares on a per user basis. -drive_map(@username); - -# Map shares based on the Operating System. -drive_map(@ostype); - -# Map shares only if they are in a group -# This line checks against the unix "groups" command, to see the secondary groups of a user. -my @usergroups = split( /\s/, do { open my $groups, "-|", groups => $user; <$groups> } ); -foreach (@usergroups) { - my $groupmap = "groupmap.$_"; - my @groupname = $cfg->param($groupmap); - drive_map(@groupname); -} - -#Here is where we check the machine name against the config... -for my $key ( keys %$compname ) { - my $test = $compname->{$key}; - if ( ref $test eq 'ARRAY' ) { - foreach (@$test) { - if ( $_ eq $machine ) { - my $preformit = $cfg->param("preformcommands.$key"); - if ( defined($preformit) ) { - if ( ref $preformit ) { - foreach (@$preformit) { print LOGON "$_ \r\n"; } - } else { - print LOGON "$preformit \r\n"; - } - } - } - } - } - elsif ( $test eq $machine ) { - my $preformit = $cfg->param("preformcommands.$key"); - if ( defined($preformit) ) { - if ( ref $preformit ) { - foreach (@$preformit) { print LOGON "$_ \r\n"; } - } else { - print LOGON "$preformit \r\n"; - } - } - } -} - -# Here is where we test the ip address against the client to see if they have "Special Mapping" -my $val; -for my $key ( sort keys %$ipname ) { - if ( ref $ipname->{$key} eq 'ARRAY' ) { - foreach ( @{ $ipname->{$key} } ) { - getipval( $_, $key ); - } - } else { - getipval( $ipname->{$key}, $key ); - } -} - -sub getipval { - my ( $range, $rangename ) = @_; - if ( parse( $ip, ipmap($range) ) ) { - if ( $val eq 'true' ) { - my $preformit = $cfg->param("preformcommands.$rangename"); - if ( defined($preformit) ) { - if ( ref $preformit ) { - foreach (@$preformit) { print LOGON "$_ \r\n"; } - } else { - print LOGON "$preformit \r\n"; - } - } - } elsif ( $val eq 'false' ) { - } - } else { - } -} - -sub ipmap { - my $pattern = shift; - my ( $iprange, $iprange2, $ipmask ); - if ( $pattern =~ m/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\/(\d{1,2})$/ ) { - # 1.1.1.1/3 notation - $iprange = pack( "U4", $1, $2, $3, $4 ); - $ipmask = pack( "U4", 0, 0, 0, 0 ); - my $numbits = $5; - for ( my $i = 0 ; $i < $numbits ; $i++ ) { - vec( $ipmask, int( $i / 8 ) * 8 + ( 8 - ( $i % 8 ) ) - 1, 1 ) = 1; - } - $iprange &= "$ipmask"; - } elsif ( $pattern =~ m/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\/(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/ ) { - # 1.1.1.1/255.255.255.255 notation - $iprange = pack( "U4", $1, $2, $3, $4 ); - $ipmask = pack( "U4", $5, $6, $7, $8 ); - $iprange &= "$ipmask"; - } elsif ( $pattern =~ m/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/ ) { - # 1.1.1.1 notation - $iprange = pack( "U4", $1, $2, $3, $4 ); - $ipmask = pack( "U4", 255, 255, 255, 255 ); - } elsif ( $pattern =~ m/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\s*\-\s*(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/ ) { - # 1.1.1.1 - 2.2.2.2 notation - $iprange = pack( "U4", $1, $2, $3, $4 ); - $iprange2 = pack( "U4", $5, $6, $7, $8 ); - $ipmask = pack( "U4", 255, 255, 255, 255 ); - } else { - return; - } - return $iprange, $ipmask, $iprange2; -} - -sub parse { - my ( $origip, $ipbase, $ipmask, $iprange2 ) = @_; - $origip =~ m/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/; - $origip = pack( "U4", $1, $2, $3, $4 ); - if ( defined($iprange2) ) { - if ( $ipbase le $origip && $origip le $iprange2 ) { - return $val = 'true'; - } else { - return $val = 'false'; - } - } elsif ( ( "$origip" & "$ipmask" ) eq $ipbase ) { - return $val = 'true'; - } else { - return $val = 'false'; - } -} - -# This sub will distinguish the drive mappings -sub drive_map { - my @data = @_; - for ( my $i = 0 ; $i < scalar(@data) ; ) { - if ( $data[$i] =~ m/^[a-z]\:$/i ) { - my $driveletter = $data[$i]; - $i++; - my $sharename = $data[$i]; - $i++; - if ( $sharename eq '/home' ) { - print LOGON uc("NET USE $driveletter $sharename \/Y \r\n"); - } else { - print LOGON - uc("NET USE $driveletter \\\\$server\\$sharename \/Y \r\n"); - } - } else { - print LOGON uc("$data[$i] \r\n"); - $i++; - } - } -} - -close(LOGON); - -sub error { - my $var = shift(@_); - help(); - print "\n\tCritical!!! \n\n\tNo $var specified\n\n\tYou must specify a $var.\n\n"; - exit(0); -} - -sub help { - - print << "EOF" ; - - Usage: $0 [options] - - Options: - - -h,--help This help screen. - - -u,--username The name of the user from the samba server. - - -m,--machinename The name of the client connecting to the server. - - -s,--server The name of the server this script is running in. - - -o,--os The clients OS -- Windows 95/98/ME (Win95), Windows NT (WinNT), - Windows 2000 (Win2K), Windows XP (WinXP), and Windows 2003 - (Win2K3). Anything else will be known as ``UNKNOWN'' - That snippet is directly from man smb.conf. - - -i,--ip The clients IP address. - - -d,--date Time and Date returned from the samba server. - - - - --IMPORTANT-- - - - All options MUST be specified. - - The mklogon.conf file MUST be located in /etc, /etc/samba, or - /usr/local/samba/lib. - - To use this file from the command line: - $0 -u User -m machine -s servername -o ostype -i X.X.X.X -d MM/DD/YY - - To use this file from the samba server add these lines to your /etc/samba/smb.conf: - - - This line goes in the [global] section - login script = %U.bat - - This line should be at the end of the [netlogon] section. - root preexec = /path/to/mklogon.pl -u %U -m %m -s %L -o %a -i %I -d %t - - -EOF - - print "\n\n"; - -} diff --git a/examples/ntlogon/README b/examples/ntlogon/README deleted file mode 100644 index e33c565d71..0000000000 --- a/examples/ntlogon/README +++ /dev/null @@ -1,160 +0,0 @@ -ntlogon.py v0.8b Copyright 2002 by Timothy (rhacer) Grant -This programme is released under the terms of the GNU Public License -This programme has NO WARRANTY of any kind, use at your own risk. - -=================== -CHANGES SINCE v0.7b -=================== -included patch that made machine name %m a macro substitution value. -Thanks to: Nick Lopez - -================== -CHANGES SINCE v0.6 -================== -PLEASE NOT THAT I AM CONSIDERING THIS A BETA UNTIL I GET SOME FEEDBACK -FROM USERS ON WHETHER THE MACRO FEATURE WORKS FOR THEM. - -added the ability to define substitution macros: see the useage section - -removed the large docstring from the file and moved the information to -the USEAGE section of this file - -cleaned up the code and made more flexible - -improved the code comments - -================== -CHANGES SINCE v0.5 -================== -added a -v --version switch - -added a --pause switch which will put a pause statement between each -non-blank line of the script. - -=============== -A PERSONAL NOTE -=============== -When I originally posted v0.5 on Freshmeat, I really expected *some* -feedback. To date this little script has been downloaded over 700 times, but -absolutely nobody has sent me an e-mail to tell me if it is useful, or if -it is absolutely the stupidest waste of bandwidth they have ever seen. -I'd really love to know if even one person other than me and the other techs -here at Avalon have found it useful. - -Thanks. - rhacer (rhacer@craigelachie.org) - -September 27, 2000 -Thanks to those that did respond to my plea! I'd still love to hear from -any other users! - -============ -INTRODUCTION -============ -As my experience with Linux and Samba increased, I had no trouble whipping up -a custom Perl, Python or Bash script to create Samba Logon Scripts, but I -noticed that I changed things from place to place, and that my users had *no* -chance of ever figuring out how to modify those scripts themselves. - -In an attempt to create a company wide standard that both my co-workers and my -customers could *easily* modify I hit upon the scheme I used here. - -I settled on an INI file feel, because most who have experience with Win boxes -have some concept of INI files. - -============ -INSTALLATION -============ -The distribution archive contains three files: - -README This file -ntlogon.py The actual Python script (place in /usr/local/samba/bin) -ntlogon.conf A sample configuration file (place in /etc) - -This script was created using Python v1.5.2, and I believe it uses only -standard libraries. - -Your smb.conf file needs to contain a netlogon section similar to the -following (These settings *are not* normal on a RH box. These settings -are all based on the excellent book that I learned Samba from: Samba -Integrating Unix and Windows by John D. Blair. It is somewhat out of -date now, but that's the history of the strange file locations): - -[netlogon] - path = /usr/local/samba/netlogon - writeable = no - guest ok = no - root preexec = /usr/local/samba/bin/ntlogon --user=%U --os=%m - root postexec = rm /usr/local/samba/netlogon/%U.bat - -====== -USEAGE -====== -PLEASE SEE NTLOGON.CONF FOR A DETAILED CONFIGURATION EXAMPLE - -This programme will build a Windows NT logon script for users connecting -to a Samba server. Samba macros that are curently understood: - - %U user name - %G group name - %a machine architecture - %m machine netbios name - -This programme reads a configuration that looks strikingly similar to both -the Samba configuration file, and a DOS "boot menu" AUTOEXEC.BAT file. - -The default file name is /etc/ntlogon.conf (though I really think it ought -to be called ntlogon.batch!) You may change the filename by using the -f -or --templatefile startup option. - -The default netlogon directory is /usr/local/samba/netlogon though this -can be changed with the -d or --dir startup option. - -The default batch file name generated is username.bat if no username is -specified the default value is logon.bat (e.g., if --user=fred is specified -on the command line then the logon script generated will be stored in -fred.bat) - -Use the --debug option to print the logon script to screen instead of the -output file - -Use the --pause option to place a pause statement between each line of the -script to assist in debugging a logon script. - -The file is divided into sections that have headers in square brackets - -[Global] -[User-username] -[Group-groupname] -[OS-osname] - -The file may also contain user defined substitution macros. They are -defined by placing the macro name on the left side of an equal sign, -and the substitution text on the right side of the equal sign. They -are also case sensitive: - -MAINDRIVE = G: -USERDRIVE = U: -SERVERNAME = myservername - -They are referenced by prepending a "%" sign to the variable name: - -NET USE %MAINDRIVE \\\\servername\\mainshare /YES -NET USE %USERDRIVE \\\\%SERVERNAME\\usershare /YES - -============== -SPECIAL THANKS -============== -Nick Lopez for the net bios name patch. - -=================== -CONTACT INFORMATION -=================== -Author : Timothy (rhacer) Grant - -I can be reached at tjg@craigelachie.org -ntlogon website www.craigelachie.org/rhacer/ntlogon - -Please feel free to contact me with any suggestions, improvements, bugs you -might find. - diff --git a/examples/ntlogon/ntlogon.conf b/examples/ntlogon/ntlogon.conf deleted file mode 100644 index e1573a6118..0000000000 --- a/examples/ntlogon/ntlogon.conf +++ /dev/null @@ -1,44 +0,0 @@ -# Everything in the Global section applies to all users logging on to the -# network -[Global] - -#Some substitution macro definitions -MAINDRIVE = G: -USERDRIVE = U: -SERVERNAME = myservername - -@ECHO "Welcome to our network!!!" -NET TIME \\servername /SET /YES -NET USE %MAINDRIVE \\%SERVERNAME\globalshare /YES - -# Map the private user area in the global section so we don't have to -# create individual user entries for each user! -NET USE %USERDRIVE \\servername\%U /YES - -# Group entries, User entries and OS entries each start with the -# keyword followed by a dash followed by--appropriately enough the Group -# name, the User name, or the OS name. -[Group-admin] -@ECHO "Welcome administrators!" -NET USE G: \\servername\adminshare1 /YES -NET USE I: \\servername\adminshare2 /YES - -[Group-peons] -@ECHO "Be grateful we let you use computers!" -NET USE G: \\servername\peonshare1 /YES - -[Group-hackers] -@ECHO "What can I do for you today great one?" -NET USE G: \\servername\hackershare1 /YES -NET USE I: \\servername\adminshare2 /YES - -[User-fred] -@ECHO "Hello there Fred!" -NET USE F: \\servername\fredsspecialshare /YES - -[OS-WfWg] -@ECHO "Time to upgrade isn't it?" - -# End configuration file - -X = Will this break? diff --git a/examples/ntlogon/ntlogon.py b/examples/ntlogon/ntlogon.py deleted file mode 100755 index ba46ba8ffc..0000000000 --- a/examples/ntlogon/ntlogon.py +++ /dev/null @@ -1,376 +0,0 @@ -#!/usr/bin/env python -""" -ntlogon.py written by Timothy (rhacer) Grant - -Copyright 1999 - 2002 by Timothy Grant - -is distributed under the terms of the GNU Public License. - -The format for the configuration file is as follows: - -While there is some room for confusion, we attempt to process things in -order of specificity: Global first, Group second, User third, OS Type -forth. This order can be debated forever, but it seems to make the most -sense. - -# Everything in the Global section applies to all users logging on to the -# network -[Global] -@ECHO "Welcome to our network!!!" -NET TIME \\\\servername /SET /YES -NET USE F: \\\\servername\\globalshare /YES - -# Map the private user area in the global section so we don't have to -# create individual user entries for each user! -NET USE U: \\\\servername\\%U /YES - -# Group entries, User entries and OS entries each start with the -# keyword followed by a dash followed by--appropriately enough the Group -# name, the User name, or the OS name. -[Group-admin] -@ECHO "Welcome administrators!" -NET USE G: \\\\servername\\adminshare1 /YES -NET USE I: \\\\servername\\adminshare2 /YES - -[Group-peons] -@ECHO "Be grateful we let you use computers!" -NET USE G: \\\\servername\\peonshare1 /YES - -[Group-hackers] -@ECHO "What can I do for you today great one?" -NET USE G: \\\\servername\\hackershare1 /YES -NET USE I: \\\\servername\\adminshare2 /YES - -[User-fred] -@ECHO "Hello there Fred!" -NET USE F: \\\\servername\\fredsspecialshare /YES - -[OS-WfWg] -@ECHO "Time to upgrade it?" - -# End configuration file - -usage: ntlogon [-g | --group=groupname] - [-u | --user=username] - [-o | --os=osname] - [-m | --machine=netbiosname] - [-f | --templatefile=filename] - [-d | --dir=netlogon directory] - [-v | --version] - [-h | --help] - [--pause] - [--debug] -""" -# -#" This quote mark is an artifact of the inability of my editor to -# correctly colour code anything after the triple-quoted docstring. -# if your editor does not have this flaw, feel free to remove it. - - -import sys -import getopt -import re -import string -import os - -version = "ntlogon.py v0.8" - -def buildScript(buf, sections, group, user, ostype, machine, debug, pause): - """ - buildScript() Takes the contents of the template file and builds - a DOS batch file to be executed as an NT logon script. It does this - by determining which sections of the configuration file should be included - and creating a list object that contains each line contained in each - included section. The list object is then returned to the calling - routine. - - All comments (#) are removed. A REM is inserted to show - which section of the configuration file each line comes from. - We leave blanklines as they are sometimes useful for debugging - - We also replace all of the Samba macros (e.g., %U, %G, %a, %m) with their - expanded versions which have been passed to us by smbd - """ - hdrstring = '' - script = [] - - # - # These are the Samba macros that we currently know about. - # any user defined macros will also be added to this dictionary. - # We do not store the % sign as part of the macro name. - # The replace routine will prepend the % sign to all possible - # replacements. - # - macros = { - 'U': user, - 'G': group, - 'a': ostype, - 'm': machine - } - - # - # Process each section defined in the list sections - # - for s in sections: - # print 'searching for: ' + s - - idx = 0 - - while idx < len(buf): - ln = buf[idx] - - # - # We need to set up a regex for each possible section we - # know about. This is slightly complicated due to the fact - # that section headers contain user defined text. - # - if s == 'Global': - hdrstring = '\[ *' + s + ' *\]' - elif s == 'Group': - hdrstring = '\[ *' + s + ' *- *' + group + ' *\]' - elif s == 'User': - hdrstring = '\[ *' + s + ' *- *' + user + ' *\]' - elif s == 'OS': - hdrstring = '\[ *' + s + ' *- *' + ostype + ' *\]' - elif s == 'Machine': - hdrstring = '\[ *' + s + ' *- *' + machine + ' *\]' - - # - # See if we have found a section header - # - if re.search(r'(?i)' + hdrstring, ln): - idx = idx + 1 # increment the counter to move to the next - # line. - - x = re.match(r'([^#\r\n]*)', ln) # Determine the section - # name and strip out CR/LF - # and comment information - - if debug: - print 'rem ' + x.group(1) + ' commands' - else: - # create the rem at the beginning of each section of the - # logon script. - script.append('rem ' + x.group(1) + ' commands') - - # - # process each line until we have found another section - # header - # - while not re.search(r'.*\[.*\].*', buf[idx]): - - # - # strip comments and line endings - # - x = re.match(r'([^#\r\n]*)', buf[idx]) - - if string.strip(x.group(1)) != '' : - # if there is still content after stripping comments and - # line endings then this is a line to process - - line = x.group(1) - - # - # Check to see if this is a macro definition line - # - vardef = re.match(r'(.*)=(.*)', line) - - if vardef: - varname = string.strip(vardef.group(1)) # Strip leading and - varsub = string.strip(vardef.group(2)) # and trailing spaces - - if varname == '': - print "Error: No substition name specified line: %d" % idx - sys.exit(1) - - if varsub == '': - print "Error: No substitution text provided line: %d" % idx - sys.exit(1) - - if macros.has_key(varname): - print "Warning: macro %s redefined line: %d" % (varname, idx) - - macros[varname] = varsub - idx = idx + 1 - continue - - # - # Replace all the macros that we currently - # know about. - # - # Iterate over the dictionary that contains all known - # macro substitutions. - # - # We test for a macro name by prepending % to each dictionary - # key. - # - for varname in macros.keys(): - line = re.sub(r'%' + varname + r'(\W)', - macros[varname] + r'\1', line) - - if debug: - print line - if pause: - print 'pause' - else: - script.append(line) - - idx = idx + 1 - - if idx == len(buf): - break # if we have reached the end of the file - # stop processing. - - idx = idx + 1 # increment the line counter - - if debug: - print '' - else: - script.append('') - - return script - -# End buildScript() - -def run(): - """ - run() everything starts here. The main routine reads the command line - arguments, opens and reads the configuration file. - """ - configfile = '/etc/ntlogon.conf' # Default configuration file - group = '' # Default group - user = '' # Default user - ostype = '' # Default os - machine = '' # Default machine type - outfile = 'logon.bat' # Default batch file name - # this file name WILL take on the form - # username.bat if a username is specified - debug = 0 # Default debugging mode - pause = 0 # Default pause mode - outdir = '/usr/local/samba/netlogon/' # Default netlogon directory - - sections = ['Global', 'Machine', 'OS', 'Group', 'User'] # Currently supported - # configuration file - # sections - - options, args = getopt.getopt(sys.argv[1:], 'd:f:g:ho:u:m:v', - ['templatefile=', - 'group=', - 'help', - 'os=', - 'user=', - 'machine=', - 'dir=', - 'version', - 'pause', - 'debug']) - - # - # Process the command line arguments - # - for i in options: - # template file to process - if (i[0] == '-f') or (i[0] == '--templatefile'): - configfile = i[1] - # print 'configfile = ' + configfile - - # define the group to be used - elif (i[0] == '-g') or (i[0] == '--group'): - group = i[1] - # print 'group = ' + group - - # define the os type - elif (i[0] == '-o') or (i[0] == '--os'): - ostype = i[1] - # print 'os = ' + os - - # define the user - elif (i[0] == '-u') or (i[0] == '--user'): - user = i[1] - outfile = user + '.bat' # Setup the output file name - # print 'user = ' + user - - # define the machine - elif (i[0] == '-m') or (i[0] == '--machine'): - machine = i[1] - - # define the netlogon directory - elif (i[0] == '-d') or (i[0] == '--dir'): - outdir = i[1] - # print 'outdir = ' + outdir - - # if we are asked to turn on debug info, do so. - elif (i[0] == '--debug'): - debug = 1 - # print 'debug = ' + debug - - # if we are asked to turn on the automatic pause functionality, do so - elif (i[0] == '--pause'): - pause = 1 - # print 'pause = ' + pause - - # if we are asked for the version number, print it. - elif (i[0] == '-v') or (i[0] == '--version'): - print version - sys.exit(0) - - # if we are asked for help print the docstring. - elif (i[0] == '-h') or (i[0] == '--help'): - print __doc__ - sys.exit(0) - - # - # open the configuration file - # - try: - iFile = open(configfile, 'r') - except IOError: - print 'Unable to open configuration file: ' + configfile - sys.exit(1) - - - # - # open the output file - # - if not debug: - try: - oFile = open(outdir + outfile, 'w') - except IOError: - print 'Unable to open logon script file: ' + outdir + outfile - sys.exit(1) - - buf = iFile.readlines() # read in the entire configuration file - - # - # call the script building routine - # - script = buildScript(buf, sections, group, user, ostype, machine, debug, pause) - - # - # write out the script file - # - if not debug: - for ln in script: - oFile.write(ln + '\r\n') - if pause: - if string.strip(ln) != '': # Because whitespace - oFile.write('pause' + '\r\n') # is a useful tool, we - # don't put pauses after - # an empty line. - - -# End run() - -# -# immediate-mode commands, for drag-and-drop or execfile() execution -# -if __name__ == '__main__': - run() -else: - print "Module ntlogon.py imported." - print "To run, type: ntlogon.run()" - print "To reload after changes to the source, type: reload(ntlogon)" - -# -# End NTLogon.py -# diff --git a/examples/scripts/backtrace b/examples/scripts/backtrace deleted file mode 100644 index 2ea6a4d00a..0000000000 --- a/examples/scripts/backtrace +++ /dev/null @@ -1,41 +0,0 @@ -#! /bin/sh -# -# Author: Andrew Tridgell - -# we want everything on stderr, so the program is not disturbed -exec 1>&2 - -BASENAME=$( basename $0) - -test -z ${GDB_BIN} && GDB_BIN=$( type -p gdb) -if [ -z ${GDB_BIN} ]; then - echo "ERROR: ${BASENAME} needs an installed gdb. " - exit 1 -fi - -if [ -z $1 ]; then - echo "ERROR: ${BASENAME} needs a PID. " - exit 1 -fi -PID=$1 - -# use /dev/shm as default temp directory -test -d /dev/shm && \ - TMP_BASE_DIR=/dev/shm || \ - TMP_BASE_DIR=/var/tmp -TMPFILE=$( mktemp -p ${TMP_BASE_DIR} backtrace.XXXXXX) -if [ $? -ne 0 ]; then - echo "ERROR: ${basename} can't create temp file in ${TMP_BASE_DIR}. " - exit 1 -fi - -cat << EOF > "${TMPFILE}" -set height 0 -up 8 -bt full -quit -EOF - -${GDB_BIN} -x "${TMPFILE}" "/proc/${PID}/exe" "${PID}" - -/bin/rm -f "${TMPFILE}" diff --git a/examples/scripts/debugging/linux/backtrace b/examples/scripts/debugging/linux/backtrace new file mode 100644 index 0000000000..2ea6a4d00a --- /dev/null +++ b/examples/scripts/debugging/linux/backtrace @@ -0,0 +1,41 @@ +#! /bin/sh +# +# Author: Andrew Tridgell + +# we want everything on stderr, so the program is not disturbed +exec 1>&2 + +BASENAME=$( basename $0) + +test -z ${GDB_BIN} && GDB_BIN=$( type -p gdb) +if [ -z ${GDB_BIN} ]; then + echo "ERROR: ${BASENAME} needs an installed gdb. " + exit 1 +fi + +if [ -z $1 ]; then + echo "ERROR: ${BASENAME} needs a PID. " + exit 1 +fi +PID=$1 + +# use /dev/shm as default temp directory +test -d /dev/shm && \ + TMP_BASE_DIR=/dev/shm || \ + TMP_BASE_DIR=/var/tmp +TMPFILE=$( mktemp -p ${TMP_BASE_DIR} backtrace.XXXXXX) +if [ $? -ne 0 ]; then + echo "ERROR: ${basename} can't create temp file in ${TMP_BASE_DIR}. " + exit 1 +fi + +cat << EOF > "${TMPFILE}" +set height 0 +up 8 +bt full +quit +EOF + +${GDB_BIN} -x "${TMPFILE}" "/proc/${PID}/exe" "${PID}" + +/bin/rm -f "${TMPFILE}" diff --git a/examples/scripts/debugging/solaris/README b/examples/scripts/debugging/solaris/README new file mode 100644 index 0000000000..9e336805e5 --- /dev/null +++ b/examples/scripts/debugging/solaris/README @@ -0,0 +1,28 @@ +Last update: John H Terpstra - June 27, 2005 + +Subject: This directory will contain debugging tools and tips. + +Notes: Identification and confirmation of some bugs can be difficult. + When such bugs are encountered it is necessary to provide as + sufficient detailed debugging information to assist the developer + both by providing incontrivertable proof of the problem, but also + precise information regarding the values of variables being processed + at the time the problem strikes. + + This directory is the ideal place to locate useful hints, tips and + methods that will help Samba users to provide the information that + developers need. + +============================ Solaris Method A ============================== +File: solaris-oops.sh +Contributor: David Collier-Brown +Date: June 27, 2005 +Method and Use: +To the global stanza of smb.conf add: + panic action = /usr/local/bin/solaris-oops.sh %d + +When the panic action is initiated a voluntary core dump file will be placed +in /var/tmp. Use this method with "log level = 10" and an smbd binary that +has been built with the '-g' option. +============================================================================ + diff --git a/examples/scripts/debugging/solaris/solaris-oops.sh b/examples/scripts/debugging/solaris/solaris-oops.sh new file mode 100644 index 0000000000..82c49efdf6 --- /dev/null +++ b/examples/scripts/debugging/solaris/solaris-oops.sh @@ -0,0 +1,55 @@ +#!/bin/sh +# +# solaris_panic_action -- capture supporting information after a failure +# +ProgName=`basename $0` +LOGDIR=/usr/local/samba/var + +main() { + pid=$1 + + if [ $# -lt 1 ]; then + say "$ProgName error: you must supply a pid" + say "Usage: $0 pid" + exit 1 + fi + cat >>$LOGDIR/log.solaris_panic_action <&2 +} + +main "$@" diff --git a/examples/scripts/perl/modify_samba_config.pl b/examples/scripts/perl/modify_samba_config.pl deleted file mode 100755 index ad958625d6..0000000000 --- a/examples/scripts/perl/modify_samba_config.pl +++ /dev/null @@ -1,154 +0,0 @@ -#!/usr/bin/perl - -## -## Simple example of how to implement a '[add|delete] share command' for -## use with the Windows NT Server Manager. See smb.conf(5) for details -## on the '[add|delete] share command' -## -## Author : Gerald (Jerry) Carter -## - -use POSIX qw(tmpnam); - -## -## local variables -## -my $delete_mode = undef; -my $add_mode = undef; -my $tmp_file_name = undef; - - -## check for correct parameters -if ($#ARGV == 1) { - $delete_mode = 1; -} -elsif ($#ARGV == 3) { - $add_mode = 1; -} -else { - print "Usage: $0 configfile share [path] [comment]\n"; - exit -1; -} - -## first param is always the config file -open (CONFIGFILE, "$ARGV[0]") || die "Unable to open $ARGV[0] for reading!\n"; - -## FIXME!! Right now we throw away all comments in the file. -while () { - - chomp($_); - - ## eat leading whitespace - $_ =~ s/^\s*//; - - ## eat trailing whitespace - $_ =~ s/\s*$//; - - - ## throw away comments - next if (($_ =~ /^#/) || ($_ =~ /^;/)); - - ## set the current section name for storing the hash - if ($_ =~ /^\[.*\]$/) { - - $_ = substr($_, 1, length($_)-2); - - if ( length($_) ) { - $section = $_; - } - else { - print "Bad Section Name - no closing ]\n"; - exit -1; - } - - next; - } - - ## check for a param = value - if ($_ =~ /=/) { - ($param, $value) = split (/=/, $_,2); - $param =~ s/./\l$&/g; - $param =~ s/\s+//g; - $value =~ s/^\s+//; - - $config{$section}{$param} = $value; - - next; - } - - ## should have a hash of hashes indexed by section name -} -close (CONFIGFILE); - -## -## We have the smb.conf in our hash of hashes now. -## Add or delete -## -if ($add_mode) { - $config{$ARGV[1]}{'path'} = $ARGV[2]; - $config{$ARGV[1]}{'comment'} = $ARGV[3]; -} -elsif ($delete_mode) { - delete $config{$ARGV[1]}; -} - -## -## Print the resulting configuration -## -#do { -# $tmp_file_name = tmpnam(); -# print "Using temporary file - $tmp_file_name\n"; -#} while (!sysopen(TMP, $tmp_file_name, O_RDWR|O_CREAT|O_EXCL)); -$tmp_file_name = tmpnam(); -open (TMP, ">$tmp_file_name") || die "Unable to open temporary file for writing!\n"; - -PrintConfigFile(TMP); - -## now overwrite the original config file -close (TMP); -system ("cp -pf $ARGV[0] $ARGV[0].bak"); -system ("cp -pf $tmp_file_name $ARGV[0]"); -unlink $tmp_file_name; - - -exit 0; - - - - - -####################################################################################### -## PrintConfigFile() -## -sub PrintConfigFile { - my ($output) = @_; - - ## print the file back out, beginning with the global section - print $output "#\n# Generated by $0\n#\n"; - - PrintSection ($output, 'global', $config{'global'}); - - foreach $section (keys %config) { - - if ("$section" ne "global") { - print $output "## Section - [$section]\n"; - PrintSection ($output, $section, $config{$section}); - } - } - - print $output "#\n# end of generated smb.conf\n#\n"; -} - -####################################################################################### -## PrintSection() -## -sub PrintSection { - my ($outfile, $name, $section) = @_; - - print $outfile "[$name]\n"; - foreach $param (keys %$section) { - print $outfile "\t$param".' 'x(25-length($param)). " = $$section{$param}\n"; - } - print $outfile "\n"; - -} diff --git a/examples/scripts/perl/smbaddprinter.pl b/examples/scripts/perl/smbaddprinter.pl deleted file mode 100755 index 557183140e..0000000000 --- a/examples/scripts/perl/smbaddprinter.pl +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/perl -## Add printer script for samba, APW, and cups -## Copyright (C) Jeff Hardy 2004 -## -## 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; -## ither 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., 675 Mass Ave, Cambridge, MA 02139, -## USA. - -@argv = @ARGV; - -# take in args -my $lpname=shift(@argv); # printer name -my $shname=shift(@argv); # share name -> used for CUPS queue name -my $portname=shift(@argv); # port name -my $drivername=shift(@argv); # driver name -> used for CUPS description -my $location=shift(@argv); # location -> used for CUPS device URI -my $win9x=shift(@argv); # win9x location - -#check for location syntax -#if no protocol specified... -if ($location !~ m#:/#){ - #assume an lpd printer - $location = "lpd://".$location; -} -#else, simply pass the URI on to the lpadmin command - -#run the cups lpadmin command to add the printer -system("/usr/sbin/lpadmin -p $shname -D \"$drivername\" -E -v $location"); - diff --git a/examples/scripts/perl/smbdelprinter.pl b/examples/scripts/perl/smbdelprinter.pl deleted file mode 100755 index 30daf24b35..0000000000 --- a/examples/scripts/perl/smbdelprinter.pl +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/perl -## Delete printer script for samba, APW, and cups -## Copyright (C) Gerald (Jerry) Carter 2004 -## -## 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; -## ither 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., 675 Mass Ave, Cambridge, MA 02139, -## USA. - -@argv = @ARGV; - -# take in args -my $lpname=shift(@argv); # printer name - -system("/usr/sbin/lpadmin -x $lpname"); - diff --git a/examples/scripts/printing/cups/smbaddprinter.pl b/examples/scripts/printing/cups/smbaddprinter.pl new file mode 100755 index 0000000000..557183140e --- /dev/null +++ b/examples/scripts/printing/cups/smbaddprinter.pl @@ -0,0 +1,41 @@ +#!/usr/bin/perl +## Add printer script for samba, APW, and cups +## Copyright (C) Jeff Hardy 2004 +## +## 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; +## ither 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., 675 Mass Ave, Cambridge, MA 02139, +## USA. + +@argv = @ARGV; + +# take in args +my $lpname=shift(@argv); # printer name +my $shname=shift(@argv); # share name -> used for CUPS queue name +my $portname=shift(@argv); # port name +my $drivername=shift(@argv); # driver name -> used for CUPS description +my $location=shift(@argv); # location -> used for CUPS device URI +my $win9x=shift(@argv); # win9x location + +#check for location syntax +#if no protocol specified... +if ($location !~ m#:/#){ + #assume an lpd printer + $location = "lpd://".$location; +} +#else, simply pass the URI on to the lpadmin command + +#run the cups lpadmin command to add the printer +system("/usr/sbin/lpadmin -p $shname -D \"$drivername\" -E -v $location"); + diff --git a/examples/scripts/printing/cups/smbdelprinter.pl b/examples/scripts/printing/cups/smbdelprinter.pl new file mode 100755 index 0000000000..30daf24b35 --- /dev/null +++ b/examples/scripts/printing/cups/smbdelprinter.pl @@ -0,0 +1,27 @@ +#!/usr/bin/perl +## Delete printer script for samba, APW, and cups +## Copyright (C) Gerald (Jerry) Carter 2004 +## +## 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; +## ither 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., 675 Mass Ave, Cambridge, MA 02139, +## USA. + +@argv = @ARGV; + +# take in args +my $lpname=shift(@argv); # printer name + +system("/usr/sbin/lpadmin -x $lpname"); + diff --git a/examples/scripts/python/SambaConfig.py b/examples/scripts/python/SambaConfig.py deleted file mode 100644 index c70c23118a..0000000000 --- a/examples/scripts/python/SambaConfig.py +++ /dev/null @@ -1,315 +0,0 @@ -import sys, string, SambaParm -from smbparm import parm_table - -###################################################################### -## -## smb.conf parser class -## -## Copyright (C) Gerald Carter 2004. -## -## 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., 675 Mass Ave, Cambridge, MA 02139, USA. -## -###################################################################### - - -##################################################################### -## multi line Samba comment -class SambaComment: - - def __init__( self, comment ): - self.comment = comment - - def Dump( self, stream, whitespace=None ): - if not self.comment: - return - for line in self.comment: - if whitespace: - stream.write( whitespace ) - stream.write( line ) - stream.write( "\n" ) - - -##################################################################### -## string smb.conf parms -class SambaParameter : - - ## indexs into the parm table tuples - DisplayName = 0 - ObjectType = 1 - DefaultValue = 2 - Scope = 3 - - ## Stores a key into the parm_table and creates an - ## SambaParmXXX object to store the value - def __init__( self, name, value, comment=None ): - self.key = string.upper(string.strip(name)) - self.comment = None - assert parm_table.has_key( self.key ), "Bad parameter name! [%s]" % name - self.parm = parm_table[self.key][self.ObjectType]( value ) - if comment : - self.comment = SambaComment( comment ) - - #if not self.parm.valid: - # self.parm.SetValue( parm_table[self.key][self.DefaultValue] ) - - ## simple test for global or service parameter scope - def isGlobalParm( self ) : - return parm_table[self.key][Scope] - - ## dump 1` character so setup the result - if not result: - result = "" - - ## Check for comments -- terminated by \n -- no continuation - - if input_str[0] == '#' or input_str[0] == ';' : - result = input_str - break - - ## check for line continuation - - if input_str[-1] == "\\" : - result += input_str[0:-1] - contine - - ## otherwise we have a complete line - result += input_str - break - - return result - - ## convert the parameter name to a form suitable as a dictionary key - def NormalizeParamName( self, param ): - return string.upper( string.join(string.split(param), "") ) - - ## Open the file and parse it into a services dictionary - ## if possible - def ReadConfig( self, filename ): - self.filename = filename - - try: - fconfig = open( filename, "r" ) - except IOError: - self.valid = False - return - - section_name = None - - ## the most recent seen comment is stored as an array - current_comment = [] - - while True: - - str = self.ReadLine( fconfig ) - if not str: - break - - ## Check for comments - if str[0] == '#' or str[0] == ';' : - current_comment.append( str ) - continue - - ## look for a next section name - if str[0]=='[' and str[-1]==']' : - section_name = str[1:-1] - self.AddService( section_name, current_comment ) - current_comment = [] - continue - - str_list = string.split( str, "=" ) - - if len(str_list) != 2 : - continue - - if not section_name : - print "parameter given without section name!" - break - - param = self.NormalizeParamName( str_list[0] ) - value = string.strip(str_list[1]) - - self.SetServiceOption( section_name, param, value, current_comment ) - self.dirty = False - - ## reset the comment strinf if we have one - current_comment = [] - - fconfig.close() - - ## Add a parameter to the global section - def SetGlobalOption( self, param, value, comment=None ) : - self.SetServiceOption( "GLOBAL", param, value, comment ) - - ## Add a parameter to a specific service - def SetServiceOption( self, servicename, param, value, comment=None ) : - service = string.upper(servicename) - parm = self.NormalizeParamName(param) - self.services[service]['_order_'].append( parm ) - self.services[service][parm] = SambaParameter( parm, value, comment ) - self.dirty = True - - ## remove a service from the config file - def DelService( self, servicename ) : - service = string.upper(servicename) - self.services[service] = None - self.dirty = True - - ## remove a service from the config file - def AddService( self, servicename, comment=None ) : - service = string.upper(servicename) - - self.services[service] = {} - self.services[service]['_order_'] = [] - - if ( comment ): - self.services[service]['_comment_'] = SambaComment( comment ) - - self.services_order.append( service ) - - self.dirty = True - - def isService( self, servicename ): - service = string.upper(servicename) - return self.services.has_key( service ) - - ## dump a single service to stream - def DumpService( self, stream, servicename ): - - ## comments first - if self.services[servicename].has_key( '_comment_' ): - self.services[servicename]['_comment_'].Dump( stream ) - - ## section header - stream.write( "[%s]\n" % (servicename) ) - - ## parameter = value - for parm in self.services[servicename]['_order_']: - self.services[servicename][parm].Dump(stream) - - ## dump the config to stream - def Dump( self, stream ): - self.DumpService( stream, "GLOBAL" ) - stream.write("\n") - - for section in self.services_order: - ## already handled the global section - if section == "GLOBAL": - continue - - ## check for deleted sections ## - if not self.services[section]: - continue - - self.DumpService( stream, section ) - stream.write( "\n" ) - - ## write out any changes to disk - def Flush( self ): - if not self.dirty: - return - - try: - fconfig = open( self.filename, "w" ) - except IOError: - sys.stderr.write( "ERROR!\n" ) - return 1 - - self.Dump( fconfig ) - fconfig.close() - return 0 - - def Services( self ): - service_list = [] - for section in self.services.keys(): - service_list.append( section ) - - return service_list - - def NumServices( self ): - return len(self.Services()) - - def Write( self, filename ): - self.filename = filename - self.valid = True - - if not self.dirty: - return - - self.Flush() - - - -###################################################################### -## Unit tests -###################################################################### - -if __name__ == "__main__" : - - x = SambaConf( ) - x.ReadConfig( sys.argv[1] ) - if not x.valid : - print "Bad file!" - sys.exit(1) - - x.Dump( sys.stdout ) - - - -## end of SambaConfig.py ###################################################### -############################################################################### - diff --git a/examples/scripts/python/SambaParm.py b/examples/scripts/python/SambaParm.py deleted file mode 100644 index 292ad42cd2..0000000000 --- a/examples/scripts/python/SambaParm.py +++ /dev/null @@ -1,84 +0,0 @@ -###################################################################### -## -## smb.conf parameter classes -## -## Copyright (C) Gerald Carter 2004. -## -## 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., 675 Mass Ave, Cambridge, MA 02139, USA. -## -###################################################################### - -import string - -##################################################################### -## Base class for Samba smb.conf parameters -class SambaParm : - def __init__( self ) : - pass - - def StringValue( self ) : - return self.value - -##################################################################### -## Boolean smb,conf parm -class SambaParmBool( SambaParm ): - def __init__( self, value ) : - x = string.upper(value) - self.valid = True - - if x=="YES" or x=="TRUE" or x=="1": - self.value = True - elif x=="NO" or x=="FALSE" or x=="0": - self.value = False - else: - self.valid = False - return self - - def SetValue( self, value ) : - x = string.upper(value) - self.valid = True - - if x=="YES" or x=="TRUE" or x=="1": - self.value = True - elif x=="NO" or x=="FALSE" or x=="0": - self.value = False - else: - self.valid = False - return - - def StringValue( self ) : - if self.value : - return "yes" - else: - return "no" - -##################################################################### -## Boolean smb,conf parm (inverts) -class SambaParmBoolRev( SambaParmBool ) : - def __init__( self, value ): - SambaParmBool.__init__( self, value ) - if self.valid : - self.value = not self.value - - -##################################################################### -## string smb.conf parms -class SambaParmString( SambaParm ): - def __init__( self, value ): - self.value = value - self.valid = True - - - diff --git a/examples/scripts/python/generate_parm_table.py b/examples/scripts/python/generate_parm_table.py deleted file mode 100755 index 1dbc071e9b..0000000000 --- a/examples/scripts/python/generate_parm_table.py +++ /dev/null @@ -1,224 +0,0 @@ -#!/usr/bin/env python -###################################################################### -## -## Generate parameter dictionary from param/loadparm.c -## -## Copyright (C) Gerald Carter 2004. -## -## 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., 675 Mass Ave, Cambridge, MA 02139, USA. -## -###################################################################### - -import re, string, sys, commands - -HEADER = """###################################################################### -## -## autogenerated file of smb.conf parameters -## generate_parm_table <..../param/loadparm.c> -## -## Copyright (C) Gerald Carter 2004. -## -## 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., 675 Mass Ave, Cambridge, MA 02139, USA. -## -###################################################################### - -from SambaParm import SambaParmString, SambaParmBool, SambaParmBoolRev - -## boolean defines for parm_table -P_LOCAL = 0 -P_GLOBAL = 1 - -""" - -FOOTER = """##### end of smbparm.y ########################################## -#################################################################""" - -TESTPARM = "/usr/bin/testparm" - -## fields in Samba's parameter table -displayName = 0 -type = 1 -scope = 2 -variable = 3 -flags = 6 - -parm_table = {} -var_table = {} -def_values = {} -obj_table = { - 'P_BOOL' : 'SambaParmBool', - 'P_BOOLREV' : 'SambaParmBoolRev', - 'P_STRING' : 'SambaParmString', - 'P_USTRING' : 'SambaParmString', - 'P_GSTRING' : 'SambaParmString', - 'P_LIST' : 'SambaParmString', - 'P_ENUM' : 'SambaParmString', - 'P_CHAR' : 'SambaParmString', - 'P_OCTAL' : 'SambaParmString', - 'P_INTEGER' : 'SambaParmString', -} - -###################################################################### -## BEGIN MAIN CODE ## -###################################################################### - -## First thing is to build the dictionary of parmeter names ## -## based on the output from testparm ## - -cmd = "/usr/bin/testparm -s -v /dev/null" -( status, testparm_output ) = commands.getstatusoutput( cmd ) -if status: - sys.stderr.write( "Failed to execute testparm!\n%s\n" % testparm_output ) - - -## break the output into a list ## - -lines = string.split( testparm_output, "\n" ) - -## loop through list -- parameters in testparm output have ## -## whitespace at the beginning of the line ## - -pattern = re.compile( "^\s+" ) -for input_str in lines: - if not pattern.search( input_str ): - continue - input_str = string.strip( input_str ) - parts = string.split( input_str, "=" ) - parts[0] = string.strip( parts[0] ) - parts[1] = string.strip( parts[1] ) - key = string.upper( string.join(string.split(parts[0]), "") ) - new = parts[1].replace('\\', '\\\\') - def_values[key] = new - -## open loadparm.c and get the entire list of parameters ## -## including synonums ## - -if len(sys.argv) != 2: - print "Usage: %s <.../param/loadparm.c>" % ( sys.argv[0] ) - sys.exit( 1 ) - -try: - fconfig = open( sys.argv[1], "r" ) -except IOError: - print "%s does not exist!" % sys.argv[1] - sys.exit (1) - -## Loop through loadparm.c -- all parameters are either ## -## P_LOCAL or P_GLOBAL ## - -synonyms = [] -pattern = re.compile( '{".*P_[GL]' ) -while True: - input_str= fconfig.readline() - if len(input_str) == 0 : - break - input_str= string.strip(input_str) - - ## see if we have a patch for a parameter definition ## - - parm = [] - if pattern.search( input_str) : - - ## strip the surrounding '{.*},' ## - - input_str= input_str[1:-2] - parm = string.split(input_str, ",") - - ## strip the ""'s and upper case ## - - name = (string.strip(parm[displayName])[1:-1]) - key = string.upper( string.join(string.split(name), "") ) - var_name = string.strip( parm[variable] ) - - - ## try to catch synonyms -- if the parameter was not reported ## - ## by testparm, then save it and come back after we will out ## - ## the variable list ## - - if not def_values.has_key( key ): - synonyms.append( input_str) - continue - - - var_table[var_name] = key - - parmType = string.strip(parm[type]) - - parm_table[key] = [ name , string.strip(parm[type]), string.strip(parm[scope]), def_values[key] ] - -## Deal with any synonyms ## - -for input_str in synonyms: - parm = string.split(input_str, ",") - name = (string.strip(parm[displayName])[1:-1]) - key = string.upper( string.join(string.split(name), "") ) - var_name = string.strip( parm[variable] ) - - ## if there's no pre-existing key, then testparm doesn't know about it - if not var_table.has_key( var_name ): - continue - - ## just make a copy - parm_table[key] = parm_table[var_table[var_name]][:] - # parm_table[key][1] = parm[1] - parm_table[key][1] = string.strip(parm[1]) - -## ## -## print out smbparm.py ## -## ## - -try: - smbparm = open ( "smbparm.py", "w" ) -except IOError: - print "Cannot write to smbparm.py" - sys.exit( 1 ) - -smbparm.write( HEADER ) -smbparm.write( "parm_table = {\n" ) - -for x in parm_table.keys(): - key = "\"%s\"" % x - smbparm.write("\t%-25s: (\"%s\", %s, %s, \"%s\"),\n" % ( key, parm_table[x][0], - obj_table[parm_table[x][1]], parm_table[x][2], parm_table[x][3] )) - -smbparm.write( "}\n" ) - -smbparm.write( FOOTER ) -smbparm.write( "\n" ) - -sys.exit(0) - - -## ## -## cut-n-paste area ## -## ## - -for x in parm_table.keys(): - if def_values.has_key( x ): - parm_table[x].append( def_values[x] ) - else: - parm_table[x].append( "" ) diff --git a/examples/scripts/python/modify_samba_config.py b/examples/scripts/python/modify_samba_config.py deleted file mode 100755 index 6a4cdcab79..0000000000 --- a/examples/scripts/python/modify_samba_config.py +++ /dev/null @@ -1,78 +0,0 @@ -#!/usr/bin/env python -###################################################################### -## -## Simple add/delete/change share command script for Samba -## -## Copyright (C) Gerald Carter 2004. -## -## 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., 675 Mass Ave, Cambridge, MA 02139, USA. -## -###################################################################### - -import sys, os -from SambaConfig import SambaConf - - -## ## -## check the command line args ## -## ## -delete_mode = False -if len(sys.argv) == 3: - delete_mode = True - print "Deleting share..." -elif len(sys.argv) == 5: - print "Adding/Updating share..." -else: - print "Usage: %s configfile share [path] [comments]" % sys.argv[0] - sys.exit(1) - - -## ## -## read and parse the config file ## -## ## - -confFile = SambaConf() - -confFile.ReadConfig( sys.argv[1] ) -if not confFile.valid: - exit( 1 ) - -if delete_mode: - if not confFile.isService( sys.argv[2] ): - sys.stderr.write( "Asked to delete non-existent service! [%s]\n" % sys.argv[2] ) - sys.exit( 1 ) - - confFile.DelService( sys.argv[2] ) -else: - ## make the path if it doesn't exist. Bail out if that fails - if ( not os.path.isdir(sys.argv[3]) ): - try: - os.makedirs( sys.argv[3] ) - os.chmod( sys.argv[3], 0777 ) - except os.error: - sys.exit( 1 ) - - ## only add a new service -- if it already exists, then - ## just set the options - if not confFile.isService( sys.argv[2] ): - confFile.AddService( sys.argv[2], ['##', '## Added by modify_samba_config.py', '##'] ) - confFile.SetServiceOption( sys.argv[2], "path", sys.argv[3] ) - confFile.SetServiceOption( sys.argv[2], "comment", sys.argv[4] ) - confFile.SetServiceOption( sys.argv[2], "read only", "no" ) - -ret = confFile.Flush() - -sys.exit( ret ) - diff --git a/examples/scripts/python/smbparm.py b/examples/scripts/python/smbparm.py deleted file mode 100644 index 0dfcf0062e..0000000000 --- a/examples/scripts/python/smbparm.py +++ /dev/null @@ -1,374 +0,0 @@ -###################################################################### -## -## autogenerated file of smb.conf parameters -## generate_parm_table <..../param/loadparm.c> -## -## Copyright (C) Gerald Carter 2004. -## -## 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., 675 Mass Ave, Cambridge, MA 02139, USA. -## -###################################################################### - -from SambaParm import SambaParmString, SambaParmBool, SambaParmBoolRev - -## boolean defines for parm_table -P_LOCAL = 0 -P_GLOBAL = 1 - -parm_table = { - "PRELOADMODULES" : ("preload modules", SambaParmString, P_GLOBAL, ""), - "ONLYGUEST" : ("guest only", SambaParmBool, P_LOCAL, "No"), - "PRIVATEDIR" : ("private dir", SambaParmString, P_GLOBAL, "/etc/samba/private"), - "HIDESPECIALFILES" : ("hide special files", SambaParmBool, P_LOCAL, "No"), - "WINBINDENUMUSERS" : ("winbind enum users", SambaParmBool, P_GLOBAL, "Yes"), - "TIMESTAMPLOGS" : ("debug timestamp", SambaParmBool, P_GLOBAL, "Yes"), - "LDAPPASSWDSYNC" : ("ldap passwd sync", SambaParmString, P_GLOBAL, "no"), - "READBMPX" : ("read bmpx", SambaParmBool, P_GLOBAL, "No"), - "PASSWORDSERVER" : ("password server", SambaParmString, P_GLOBAL, "*"), - "COPY" : ("copy", SambaParmString, P_LOCAL, ""), - "MAXXMIT" : ("max xmit", SambaParmString, P_GLOBAL, "16644"), - "MINPRINTSPACE" : ("min print space", SambaParmString, P_LOCAL, "0"), - "CASESENSITIVE" : ("case sensitive", SambaParmString, P_LOCAL, "Auto"), - "LDAPIDMAPSUFFIX" : ("ldap idmap suffix", SambaParmString, P_GLOBAL, ""), - "NAMECACHETIMEOUT" : ("name cache timeout", SambaParmString, P_GLOBAL, "660"), - "MAPARCHIVE" : ("map archive", SambaParmBool, P_LOCAL, "Yes"), - "LANMANAUTH" : ("lanman auth", SambaParmBool, P_GLOBAL, "Yes"), - "NETBIOSSCOPE" : ("netbios scope", SambaParmString, P_GLOBAL, ""), - "MAXREPORTEDPRINTJOBS" : ("max reported print jobs", SambaParmString, P_LOCAL, "0"), - "CREATEMODE" : ("create mask", SambaParmString, P_LOCAL, "0744"), - "READLIST" : ("read list", SambaParmString, P_LOCAL, ""), - "WINBINDNESTEDGROUPS" : ("winbind nested groups", SambaParmBool, P_GLOBAL, "No"), - "COMMENT" : ("comment", SambaParmString, P_LOCAL, ""), - "PRINTER" : ("printer name", SambaParmString, P_LOCAL, ""), - "LMANNOUNCE" : ("lm announce", SambaParmString, P_GLOBAL, "Auto"), - "SYSLOGONLY" : ("syslog only", SambaParmBool, P_GLOBAL, "No"), - "LMINTERVAL" : ("lm interval", SambaParmString, P_GLOBAL, "60"), - "MANGLINGMETHOD" : ("mangling method", SambaParmString, P_GLOBAL, "hash2"), - "PROFILEACLS" : ("profile acls", SambaParmBool, P_LOCAL, "No"), - "LDAPGROUPSUFFIX" : ("ldap group suffix", SambaParmString, P_GLOBAL, ""), - "MAPTOGUEST" : ("map to guest", SambaParmString, P_GLOBAL, "Never"), - "NULLPASSWORDS" : ("null passwords", SambaParmBool, P_GLOBAL, "No"), - "ONLYUSER" : ("only user", SambaParmBool, P_LOCAL, "No"), - "UTMP" : ("utmp", SambaParmBool, P_GLOBAL, "No"), - "DONTDESCEND" : ("dont descend", SambaParmString, P_LOCAL, ""), - "PRINTING" : ("printing", SambaParmString, P_LOCAL, "cups"), - "SOCKETOPTIONS" : ("socket options", SambaParmString, P_GLOBAL, "TCP_NODELAY"), - "CLIENTUSESPNEGO" : ("client use spnego", SambaParmBool, P_GLOBAL, "Yes"), - "USESPNEGO" : ("use spnego", SambaParmBool, P_GLOBAL, "Yes"), - "FAKEOPLOCKS" : ("fake oplocks", SambaParmBool, P_LOCAL, "No"), - "FORCECREATEMODE" : ("force create mode", SambaParmString, P_LOCAL, "00"), - "SETDIRECTORY" : ("set directory", SambaParmBoolRev, P_LOCAL, "No"), - "SMBPORTS" : ("smb ports", SambaParmString, P_GLOBAL, "445 139"), - "LOCKDIR" : ("lock directory", SambaParmString, P_GLOBAL, "/var/lib/samba"), - "BROWSEABLE" : ("browseable", SambaParmBool, P_LOCAL, "Yes"), - "WINSPROXY" : ("wins proxy", SambaParmBool, P_GLOBAL, "No"), - "FORCEGROUP" : ("force group", SambaParmString, P_LOCAL, ""), - "NTSTATUSSUPPORT" : ("nt status support", SambaParmBool, P_GLOBAL, "Yes"), - "EXEC" : ("preexec", SambaParmString, P_LOCAL, ""), - "DOMAINLOGONS" : ("domain logons", SambaParmBool, P_GLOBAL, "No"), - "TEMPLATESHELL" : ("template shell", SambaParmString, P_GLOBAL, "/bin/false"), - "USESENDFILE" : ("use sendfile", SambaParmBool, P_LOCAL, "No"), - "USEMMAP" : ("use mmap", SambaParmBool, P_GLOBAL, "Yes"), - "VALIDUSERS" : ("valid users", SambaParmString, P_LOCAL, ""), - "DEBUGLEVEL" : ("log level", SambaParmString, P_GLOBAL, "0"), - "PRINTCAPCACHETIME" : ("printcap cache time", SambaParmString, P_GLOBAL, "0"), - "SOCKETADDRESS" : ("socket address", SambaParmString, P_GLOBAL, "0.0.0.0"), - "FORCEDIRECTORYMODE" : ("force directory mode", SambaParmString, P_LOCAL, "00"), - "MSDFSROOT" : ("msdfs root", SambaParmBool, P_LOCAL, "No"), - "ROOTPREEXEC" : ("root preexec", SambaParmString, P_LOCAL, ""), - "WRITEOK" : ("read only", SambaParmBoolRev, P_LOCAL, "Yes"), - "MAXLOGSIZE" : ("max log size", SambaParmString, P_GLOBAL, "5000"), - "FORCESECURITYMODE" : ("force security mode", SambaParmString, P_LOCAL, "00"), - "VFSOBJECT" : ("vfs objects", SambaParmString, P_LOCAL, ""), - "CHECKPASSWORDSCRIPT" : ("check password script", SambaParmString, P_GLOBAL, ""), - "DELETEPRINTERCOMMAND" : ("deleteprinter command", SambaParmString, P_GLOBAL, ""), - "OSLEVEL" : ("os level", SambaParmString, P_GLOBAL, "20"), - "ENUMPORTSCOMMAND" : ("enumports command", SambaParmString, P_GLOBAL, ""), - "DELETEUSERFROMGROUPSCRIPT": ("delete user from group script", SambaParmString, P_GLOBAL, ""), - "IDMAPGID" : ("idmap gid", SambaParmString, P_GLOBAL, ""), - "PREEXECCLOSE" : ("preexec close", SambaParmBool, P_LOCAL, "No"), - "UTMPDIRECTORY" : ("utmp directory", SambaParmString, P_GLOBAL, ""), - "DOSFILEMODE" : ("dos filemode", SambaParmBool, P_LOCAL, "No"), - "LOGFILE" : ("log file", SambaParmString, P_GLOBAL, ""), - "WORKGROUP" : ("workgroup", SambaParmString, P_GLOBAL, "WORKGROUP"), - "DIRECTORYSECURITYMASK" : ("directory security mask", SambaParmString, P_LOCAL, "0777"), - "ENCRYPTPASSWORDS" : ("encrypt passwords", SambaParmBool, P_GLOBAL, "Yes"), - "PRINTABLE" : ("printable", SambaParmBool, P_LOCAL, "No"), - "MAXPROTOCOL" : ("max protocol", SambaParmString, P_GLOBAL, "NT1"), - "KERNELOPLOCKS" : ("kernel oplocks", SambaParmBool, P_GLOBAL, "Yes"), - "NETBIOSALIASES" : ("netbios aliases", SambaParmString, P_GLOBAL, ""), - "ANNOUNCEAS" : ("announce as", SambaParmString, P_GLOBAL, "NT"), - "DIRECTORYMASK" : ("directory mask", SambaParmString, P_LOCAL, "0755"), - "MAPSYSTEM" : ("map system", SambaParmBool, P_LOCAL, "No"), - "CHANGENOTIFYTIMEOUT" : ("change notify timeout", SambaParmString, P_GLOBAL, "60"), - "WINBINDTRUSTEDDOMAINSONLY": ("winbind trusted domains only", SambaParmBool, P_GLOBAL, "No"), - "SHUTDOWNSCRIPT" : ("shutdown script", SambaParmString, P_GLOBAL, ""), - "FOLLOWSYMLINKS" : ("follow symlinks", SambaParmBool, P_LOCAL, "Yes"), - "MAPHIDDEN" : ("map hidden", SambaParmBool, P_LOCAL, "No"), - "GROUP" : ("force group", SambaParmString, P_LOCAL, ""), - "DENYHOSTS" : ("hosts deny", SambaParmString, P_LOCAL, ""), - "WINBINDCACHETIME" : ("winbind cache time", SambaParmString, P_GLOBAL, "300"), - "DELETEVETOFILES" : ("delete veto files", SambaParmBool, P_LOCAL, "No"), - "DISABLESPOOLSS" : ("disable spoolss", SambaParmBool, P_GLOBAL, "No"), - "MAXCONNECTIONS" : ("max connections", SambaParmString, P_LOCAL, "0"), - "WRITERAW" : ("write raw", SambaParmBool, P_GLOBAL, "Yes"), - "SERVERSIGNING" : ("server signing", SambaParmString, P_GLOBAL, "No"), - "VOLUME" : ("volume", SambaParmString, P_LOCAL, ""), - "UNIXPASSWORDSYNC" : ("unix password sync", SambaParmBool, P_GLOBAL, "No"), - "OBEYPAMRESTRICTIONS" : ("obey pam restrictions", SambaParmBool, P_GLOBAL, "No"), - "PASSWDCHATTIMEOUT" : ("passwd chat timeout", SambaParmString, P_GLOBAL, "2"), - "USER" : ("username", SambaParmString, P_LOCAL, ""), - "HIDEDOTFILES" : ("hide dot files", SambaParmBool, P_LOCAL, "Yes"), - "ROOTPOSTEXEC" : ("root postexec", SambaParmString, P_LOCAL, ""), - "PROTOCOL" : ("max protocol", SambaParmString, P_GLOBAL, "NT1"), - "LDAPADMINDN" : ("ldap admin dn", SambaParmString, P_GLOBAL, ""), - "DNSPROXY" : ("dns proxy", SambaParmBool, P_GLOBAL, "Yes"), - "OS2DRIVERMAP" : ("os2 driver map", SambaParmString, P_GLOBAL, ""), - "QUEUERESUMECOMMAND" : ("queueresume command", SambaParmString, P_LOCAL, ""), - "SERVERSCHANNEL" : ("server schannel", SambaParmString, P_GLOBAL, "Auto"), - "IDMAPUID" : ("idmap uid", SambaParmString, P_GLOBAL, ""), - "WINBINDENABLELOCALACCOUNTS": ("winbind enable local accounts", SambaParmBool, P_GLOBAL, "No"), - "PRINTERNAME" : ("printer name", SambaParmString, P_LOCAL, ""), - "NTACLSUPPORT" : ("nt acl support", SambaParmBool, P_LOCAL, "Yes"), - "LOGLEVEL" : ("log level", SambaParmString, P_GLOBAL, "0"), - "STATCACHE" : ("stat cache", SambaParmBool, P_GLOBAL, "Yes"), - "LPQCACHETIME" : ("lpq cache time", SambaParmString, P_GLOBAL, "30"), - "LEVEL2OPLOCKS" : ("level2 oplocks", SambaParmBool, P_LOCAL, "Yes"), - "LARGEREADWRITE" : ("large readwrite", SambaParmBool, P_GLOBAL, "Yes"), - "LDAPREPLICATIONSLEEP" : ("ldap replication sleep", SambaParmString, P_GLOBAL, "1000"), - "SECURITYMASK" : ("security mask", SambaParmString, P_LOCAL, "0777"), - "LDAPUSERSUFFIX" : ("ldap user suffix", SambaParmString, P_GLOBAL, ""), - "NETBIOSNAME" : ("netbios name", SambaParmString, P_GLOBAL, "PANTHER"), - "LOCKSPINCOUNT" : ("lock spin count", SambaParmString, P_GLOBAL, "3"), - "OPLOCKS" : ("oplocks", SambaParmBool, P_LOCAL, "Yes"), - "MINWINSTTL" : ("min wins ttl", SambaParmString, P_GLOBAL, "21600"), - "HOMEDIRMAP" : ("homedir map", SambaParmString, P_GLOBAL, ""), - "REMOTEANNOUNCE" : ("remote announce", SambaParmString, P_GLOBAL, ""), - "PREFERREDMASTER" : ("preferred master", SambaParmString, P_GLOBAL, "Auto"), - "SECURITY" : ("security", SambaParmString, P_GLOBAL, "USER"), - "AUTHMETHODS" : ("auth methods", SambaParmString, P_GLOBAL, ""), - "ENABLERIDALGORITHM" : ("enable rid algorithm", SambaParmBool, P_GLOBAL, "Yes"), - "LPRMCOMMAND" : ("lprm command", SambaParmString, P_LOCAL, ""), - "KERNELCHANGENOTIFY" : ("kernel change notify", SambaParmBool, P_GLOBAL, "Yes"), - "LOGONSCRIPT" : ("logon script", SambaParmString, P_GLOBAL, ""), - "PRESERVECASE" : ("preserve case", SambaParmBool, P_LOCAL, "Yes"), - "UNIXCHARSET" : ("unix charset", SambaParmString, P_GLOBAL, "UTF-8"), - "FORCEPRINTERNAME" : ("force printername", SambaParmBool, P_LOCAL, "No"), - "LDAPFILTER" : ("ldap filter", SambaParmString, P_GLOBAL, "(uid"), - "DELETEREADONLY" : ("delete readonly", SambaParmBool, P_LOCAL, "No"), - "ABORTSHUTDOWNSCRIPT" : ("abort shutdown script", SambaParmString, P_GLOBAL, ""), - "DFREECOMMAND" : ("dfree command", SambaParmString, P_GLOBAL, ""), - "VETOFILES" : ("veto files", SambaParmString, P_LOCAL, ""), - "LOCKING" : ("locking", SambaParmBool, P_LOCAL, "Yes"), - "EASUPPORT" : ("ea support", SambaParmBool, P_LOCAL, "No"), - "MAXSMBDPROCESSES" : ("max smbd processes", SambaParmString, P_GLOBAL, "0"), - "HIDEFILES" : ("hide files", SambaParmString, P_LOCAL, ""), - "PASSWDCHATDEBUG" : ("passwd chat debug", SambaParmBool, P_GLOBAL, "No"), - "SMBPASSWDFILE" : ("smb passwd file", SambaParmString, P_GLOBAL, "/etc/samba/private/smbpasswd"), - "GETQUOTACOMMAND" : ("get quota command", SambaParmString, P_GLOBAL, ""), - "OPLOCKCONTENTIONLIMIT" : ("oplock contention limit", SambaParmString, P_LOCAL, "2"), - "DOMAINMASTER" : ("domain master", SambaParmString, P_GLOBAL, "Auto"), - "DELETESHARECOMMAND" : ("delete share command", SambaParmString, P_GLOBAL, ""), - "INVALIDUSERS" : ("invalid users", SambaParmString, P_LOCAL, ""), - "POSIXLOCKING" : ("posix locking", SambaParmBool, P_LOCAL, "Yes"), - "INCLUDE" : ("include", SambaParmString, P_LOCAL, ""), - "ALGORITHMICRIDBASE" : ("algorithmic rid base", SambaParmString, P_GLOBAL, "1000"), - "FORCEDIRECTORYSECURITYMODE": ("force directory security mode", SambaParmString, P_LOCAL, "00"), - "ANNOUNCEVERSION" : ("announce version", SambaParmString, P_GLOBAL, "4.9"), - "USERNAMEMAP" : ("username map", SambaParmString, P_GLOBAL, ""), - "MANGLEDNAMES" : ("mangled names", SambaParmBool, P_LOCAL, "Yes"), - "ROOTDIRECTORY" : ("root directory", SambaParmString, P_GLOBAL, ""), - "DEBUGHIRESTIMESTAMP" : ("debug hires timestamp", SambaParmBool, P_GLOBAL, "No"), - "LOGONDRIVE" : ("logon drive", SambaParmString, P_GLOBAL, ""), - "LOCALMASTER" : ("local master", SambaParmBool, P_GLOBAL, "Yes"), - "ROOTPREEXECCLOSE" : ("root preexec close", SambaParmBool, P_LOCAL, "No"), - "CONFIGFILE" : ("config file", SambaParmString, P_GLOBAL, ""), - "USECLIENTDRIVER" : ("use client driver", SambaParmBool, P_LOCAL, "No"), - "MINPROTOCOL" : ("min protocol", SambaParmString, P_GLOBAL, "CORE"), - "ADDUSERTOGROUPSCRIPT" : ("add user to group script", SambaParmString, P_GLOBAL, ""), - "MAPACLINHERIT" : ("map acl inherit", SambaParmBool, P_LOCAL, "No"), - "DELETEUSERSCRIPT" : ("delete user script", SambaParmString, P_GLOBAL, ""), - "WINBINDUID" : ("idmap uid", SambaParmString, P_GLOBAL, ""), - "READRAW" : ("read raw", SambaParmBool, P_GLOBAL, "Yes"), - "WINBINDENUMGROUPS" : ("winbind enum groups", SambaParmBool, P_GLOBAL, "Yes"), - "PASSWORDLEVEL" : ("password level", SambaParmString, P_GLOBAL, "0"), - "MAXPRINTJOBS" : ("max print jobs", SambaParmString, P_LOCAL, "1000"), - "PRINTCAP" : ("printcap name", SambaParmString, P_GLOBAL, ""), - "LOADPRINTERS" : ("load printers", SambaParmBool, P_GLOBAL, "Yes"), - "DEFAULT" : ("default service", SambaParmString, P_GLOBAL, ""), - "GUESTACCOUNT" : ("guest account", SambaParmString, P_GLOBAL, "nobody"), - "AUTOSERVICES" : ("preload", SambaParmString, P_GLOBAL, ""), - "WRITEABLE" : ("read only", SambaParmBoolRev, P_LOCAL, "Yes"), - "CLIENTLANMANAUTH" : ("client lanman auth", SambaParmBool, P_GLOBAL, "Yes"), - "MESSAGECOMMAND" : ("message command", SambaParmString, P_GLOBAL, ""), - "UNIXEXTENSIONS" : ("unix extensions", SambaParmBool, P_GLOBAL, "Yes"), - "LDAPPASSWORDSYNC" : ("ldap passwd sync", SambaParmString, P_GLOBAL, "no"), - "AFSUSERNAMEMAP" : ("afs username map", SambaParmString, P_GLOBAL, ""), - "SYSLOG" : ("syslog", SambaParmString, P_GLOBAL, "1"), - "SETPRIMARYGROUPSCRIPT" : ("set primary group script", SambaParmString, P_GLOBAL, ""), - "DEADTIME" : ("deadtime", SambaParmString, P_GLOBAL, "0"), - "RESTRICTANONYMOUS" : ("restrict anonymous", SambaParmString, P_GLOBAL, "0"), - "USERNAMELEVEL" : ("username level", SambaParmString, P_GLOBAL, "0"), - "DISPLAYCHARSET" : ("display charset", SambaParmString, P_GLOBAL, "LOCALE"), - "FORCEUSER" : ("force user", SambaParmString, P_LOCAL, ""), - "HOSTSDENY" : ("hosts deny", SambaParmString, P_LOCAL, ""), - "HIDEUNWRITEABLEFILES" : ("hide unwriteable files", SambaParmBool, P_LOCAL, "No"), - "DOSCHARSET" : ("dos charset", SambaParmString, P_GLOBAL, "CP850"), - "DOSFILETIMES" : ("dos filetimes", SambaParmBool, P_LOCAL, "No"), - "REALM" : ("realm", SambaParmString, P_GLOBAL, ""), - "LDAPSUFFIX" : ("ldap suffix", SambaParmString, P_GLOBAL, ""), - "LPPAUSECOMMAND" : ("lppause command", SambaParmString, P_LOCAL, ""), - "FAKEDIRECTORYCREATETIMES": ("fake directory create times", SambaParmBool, P_LOCAL, "No"), - "MAGICSCRIPT" : ("magic script", SambaParmString, P_LOCAL, ""), - "WRITECACHESIZE" : ("write cache size", SambaParmString, P_LOCAL, "0"), - "BLOCKSIZE" : ("block size", SambaParmString, P_LOCAL, "1024"), - "LOCKSPINTIME" : ("lock spin time", SambaParmString, P_GLOBAL, "10"), - "ACLCOMPATIBILITY" : ("acl compatibility", SambaParmString, P_GLOBAL, ""), - "MSDFSPROXY" : ("msdfs proxy", SambaParmString, P_LOCAL, ""), - "POSTEXEC" : ("postexec", SambaParmString, P_LOCAL, ""), - "HIDEUNREADABLE" : ("hide unreadable", SambaParmBool, P_LOCAL, "No"), - "WIDELINKS" : ("wide links", SambaParmBool, P_LOCAL, "Yes"), - "STRICTSYNC" : ("strict sync", SambaParmBool, P_LOCAL, "No"), - "PRINTCAPNAME" : ("printcap name", SambaParmString, P_GLOBAL, ""), - "PREFEREDMASTER" : ("preferred master", SambaParmString, P_GLOBAL, "Auto"), - "MAXMUX" : ("max mux", SambaParmString, P_GLOBAL, "50"), - "VETOOPLOCKFILES" : ("veto oplock files", SambaParmString, P_LOCAL, ""), - "WINBINDSEPARATOR" : ("winbind separator", SambaParmString, P_GLOBAL, "\\"), - "NISHOMEDIR" : ("NIS homedir", SambaParmBool, P_GLOBAL, "No"), - "AVAILABLE" : ("available", SambaParmBool, P_LOCAL, "Yes"), - "KEEPALIVE" : ("keepalive", SambaParmString, P_GLOBAL, "300"), - "USERNAME" : ("username", SambaParmString, P_LOCAL, ""), - "PRINTCOMMAND" : ("print command", SambaParmString, P_LOCAL, ""), - "LPRESUMECOMMAND" : ("lpresume command", SambaParmString, P_LOCAL, ""), - "USEKERBEROSKEYTAB" : ("use kerberos keytab", SambaParmBool, P_GLOBAL, "No"), - "HOSTSALLOW" : ("hosts allow", SambaParmString, P_LOCAL, ""), - "MAXOPENFILES" : ("max open files", SambaParmString, P_GLOBAL, "10000"), - "PARANOIDSERVERSECURITY" : ("paranoid server security", SambaParmBool, P_GLOBAL, "Yes"), - "WTMPDIRECTORY" : ("wtmp directory", SambaParmString, P_GLOBAL, ""), - "ADDPRINTERCOMMAND" : ("addprinter command", SambaParmString, P_GLOBAL, ""), - "PRINTERADMIN" : ("printer admin", SambaParmString, P_LOCAL, ""), - "WINSSERVER" : ("wins server", SambaParmString, P_GLOBAL, ""), - "LDAPTIMEOUT" : ("ldap timeout", SambaParmString, P_GLOBAL, "15"), - "LOCKDIRECTORY" : ("lock directory", SambaParmString, P_GLOBAL, "/var/lib/samba"), - "LOGONHOME" : ("logon home", SambaParmString, P_GLOBAL, "\\%N\%U"), - "MINPASSWDLENGTH" : ("min password length", SambaParmString, P_GLOBAL, "5"), - "CLIENTPLAINTEXTAUTH" : ("client plaintext auth", SambaParmBool, P_GLOBAL, "Yes"), - "CSCPOLICY" : ("csc policy", SambaParmString, P_LOCAL, "manual"), - "ADDSHARECOMMAND" : ("add share command", SambaParmString, P_GLOBAL, ""), - "MANGLINGCHAR" : ("mangling char", SambaParmString, P_LOCAL, "~"), - "DIRECTORY" : ("path", SambaParmString, P_LOCAL, ""), - "DEBUGTIMESTAMP" : ("debug timestamp", SambaParmBool, P_GLOBAL, "Yes"), - "ALLOWHOSTS" : ("hosts allow", SambaParmString, P_LOCAL, ""), - "FSTYPE" : ("fstype", SambaParmString, P_LOCAL, "NTFS"), - "BLOCKINGLOCKS" : ("blocking locks", SambaParmBool, P_LOCAL, "Yes"), - "LDAPSSL" : ("ldap ssl", SambaParmString, P_GLOBAL, ""), - "PAMPASSWORDCHANGE" : ("pam password change", SambaParmBool, P_GLOBAL, "No"), - "GUESTOK" : ("guest ok", SambaParmBool, P_LOCAL, "No"), - "DEFAULTDEVMODE" : ("default devmode", SambaParmBool, P_LOCAL, "No"), - "MAXDISKSIZE" : ("max disk size", SambaParmString, P_GLOBAL, "0"), - "ADDMACHINESCRIPT" : ("add machine script", SambaParmString, P_GLOBAL, ""), - "MANGLEPREFIX" : ("mangle prefix", SambaParmString, P_GLOBAL, "1"), - "DISABLENETBIOS" : ("disable netbios", SambaParmBool, P_GLOBAL, "No"), - "LOGONPATH" : ("logon path", SambaParmString, P_GLOBAL, "\\%N\%U\profile"), - "IDMAPBACKEND" : ("idmap backend", SambaParmString, P_GLOBAL, ""), - "SHORTPRESERVECASE" : ("short preserve case", SambaParmBool, P_LOCAL, "Yes"), - "CUPSSERVER" : ("cups server", SambaParmString, P_GLOBAL, ""), - "NTPIPESUPPORT" : ("nt pipe support", SambaParmBool, P_GLOBAL, "Yes"), - "READONLY" : ("read only", SambaParmBool, P_LOCAL, "Yes"), - "MACHINEPASSWORDTIMEOUT" : ("machine password timeout", SambaParmString, P_GLOBAL, "604800"), - "PIDDIRECTORY" : ("pid directory", SambaParmString, P_GLOBAL, "/var/run"), - "PUBLIC" : ("guest ok", SambaParmBool, P_LOCAL, "No"), - "DEBUGPID" : ("debug pid", SambaParmBool, P_GLOBAL, "No"), - "GUESTONLY" : ("guest only", SambaParmBool, P_LOCAL, "No"), - "DELETEGROUPSCRIPT" : ("delete group script", SambaParmString, P_GLOBAL, ""), - "CUPSOPTIONS" : ("cups options", SambaParmString, P_LOCAL, ""), - "PASSWDCHAT" : ("passwd chat", SambaParmString, P_GLOBAL, "*new*password* %n\n *new*password* %n\n *changed*"), - "STRICTLOCKING" : ("strict locking", SambaParmString, P_LOCAL, "Yes"), - "TEMPLATEHOMEDIR" : ("template homedir", SambaParmString, P_GLOBAL, "/home/%D/%U"), - "WINBINDGID" : ("idmap gid", SambaParmString, P_GLOBAL, ""), - "INHERITPERMISSIONS" : ("inherit permissions", SambaParmBool, P_LOCAL, "No"), - "TIMESERVER" : ("time server", SambaParmBool, P_GLOBAL, "No"), - "BROWSELIST" : ("browse list", SambaParmBool, P_GLOBAL, "Yes"), - "HOSTNAMELOOKUPS" : ("hostname lookups", SambaParmBool, P_GLOBAL, "No"), - "DOSFILETIMERESOLUTION" : ("dos filetime resolution", SambaParmBool, P_LOCAL, "No"), - "CREATEMASK" : ("create mask", SambaParmString, P_LOCAL, "0744"), - "WINSHOOK" : ("wins hook", SambaParmString, P_GLOBAL, ""), - "DEFAULTCASE" : ("default case", SambaParmString, P_LOCAL, "lower"), - "PATH" : ("path", SambaParmString, P_LOCAL, ""), - "SHOWADDPRINTERWIZARD" : ("show add printer wizard", SambaParmBool, P_GLOBAL, "Yes"), - "WINSPARTNERS" : ("wins partners", SambaParmString, P_GLOBAL, ""), - "ENABLEPRIVILEGES" : ("enable privileges", SambaParmBool, P_GLOBAL, "No"), - "VFSOBJECTS" : ("vfs objects", SambaParmString, P_LOCAL, ""), - "STRICTALLOCATE" : ("strict allocate", SambaParmBool, P_LOCAL, "No"), - "PREEXEC" : ("preexec", SambaParmString, P_LOCAL, ""), - "WINSSUPPORT" : ("wins support", SambaParmBool, P_GLOBAL, "No"), - "HOSTMSDFS" : ("host msdfs", SambaParmBool, P_GLOBAL, "No"), - "AFSTOKENLIFETIME" : ("afs token lifetime", SambaParmString, P_GLOBAL, "604800"), - "PRINTOK" : ("printable", SambaParmBool, P_LOCAL, "No"), - "TEMPLATEPRIMARYGROUP" : ("template primary group", SambaParmString, P_GLOBAL, "nobody"), - "PASSWDPROGRAM" : ("passwd program", SambaParmString, P_GLOBAL, ""), - "SYNCALWAYS" : ("sync always", SambaParmBool, P_LOCAL, "No"), - "QUEUEPAUSECOMMAND" : ("queuepause command", SambaParmString, P_LOCAL, ""), - "BINDINTERFACESONLY" : ("bind interfaces only", SambaParmBool, P_GLOBAL, "No"), - "MAXWINSTTL" : ("max wins ttl", SambaParmString, P_GLOBAL, "518400"), - "GETWDCACHE" : ("getwd cache", SambaParmBool, P_GLOBAL, "Yes"), - "MAGICOUTPUT" : ("magic output", SambaParmString, P_LOCAL, ""), - "ADMINUSERS" : ("admin users", SambaParmString, P_LOCAL, ""), - "DIRECTORYMODE" : ("directory mask", SambaParmString, P_LOCAL, "0755"), - "CLIENTSIGNING" : ("client signing", SambaParmString, P_GLOBAL, "auto"), - "PASSDBBACKEND" : ("passdb backend", SambaParmString, P_GLOBAL, "smbpasswd"), - "CASESIGNAMES" : ("case sensitive", SambaParmString, P_LOCAL, "Auto"), - "SETQUOTACOMMAND" : ("set quota command", SambaParmString, P_GLOBAL, ""), - "LPQCOMMAND" : ("lpq command", SambaParmString, P_LOCAL, ""), - "SERVERSTRING" : ("server string", SambaParmString, P_GLOBAL, "Samba 3.0.11pre2-SVN-build-4840"), - "DEFAULTSERVICE" : ("default service", SambaParmString, P_GLOBAL, ""), - "WINBINDUSEDEFAULTDOMAIN": ("winbind use default domain", SambaParmBool, P_GLOBAL, "No"), - "INTERFACES" : ("interfaces", SambaParmString, P_GLOBAL, ""), - "ROOTDIR" : ("root directory", SambaParmString, P_GLOBAL, ""), - "ADDUSERSCRIPT" : ("add user script", SambaParmString, P_GLOBAL, ""), - "CLIENTNTLMV2AUTH" : ("client NTLMv2 auth", SambaParmBool, P_GLOBAL, "No"), - "FORCEUNKNOWNACLUSER" : ("force unknown acl user", SambaParmBool, P_LOCAL, "No"), - "MANGLEDMAP" : ("mangled map", SambaParmString, P_LOCAL, ""), - "NTLMAUTH" : ("ntlm auth", SambaParmBool, P_GLOBAL, "Yes"), - "INHERITACLS" : ("inherit acls", SambaParmBool, P_LOCAL, "No"), - "HOSTSEQUIV" : ("hosts equiv", SambaParmString, P_GLOBAL, ""), - "ALLOWTRUSTEDDOMAINS" : ("allow trusted domains", SambaParmBool, P_GLOBAL, "Yes"), - "MINPASSWORDLENGTH" : ("min password length", SambaParmString, P_GLOBAL, "5"), - "USERS" : ("username", SambaParmString, P_LOCAL, ""), - "PRELOAD" : ("preload", SambaParmString, P_GLOBAL, ""), - "DEBUGUID" : ("debug uid", SambaParmBool, P_GLOBAL, "No"), - "CHANGESHARECOMMAND" : ("change share command", SambaParmString, P_GLOBAL, ""), - "BROWSABLE" : ("browseable", SambaParmBool, P_LOCAL, "Yes"), - "ENHANCEDBROWSING" : ("enhanced browsing", SambaParmBool, P_GLOBAL, "Yes"), - "PANICACTION" : ("panic action", SambaParmString, P_GLOBAL, ""), - "LDAPMACHINESUFFIX" : ("ldap machine suffix", SambaParmString, P_GLOBAL, ""), - "UPDATEENCRYPTED" : ("update encrypted", SambaParmBool, P_GLOBAL, "No"), - "MAXTTL" : ("max ttl", SambaParmString, P_GLOBAL, "259200"), - "WRITABLE" : ("read only", SambaParmBoolRev, P_LOCAL, "Yes"), - "SHAREMODES" : ("share modes", SambaParmBool, P_LOCAL, "Yes"), - "REMOTEBROWSESYNC" : ("remote browse sync", SambaParmString, P_GLOBAL, ""), - "STOREDOSATTRIBUTES" : ("store dos attributes", SambaParmBool, P_LOCAL, "No"), - "CLIENTSCHANNEL" : ("client schannel", SambaParmString, P_GLOBAL, "Auto"), - "WRITELIST" : ("write list", SambaParmString, P_LOCAL, ""), - "ADDGROUPSCRIPT" : ("add group script", SambaParmString, P_GLOBAL, ""), - "OPLOCKBREAKWAITTIME" : ("oplock break wait time", SambaParmString, P_GLOBAL, "0"), - "TIMEOFFSET" : ("time offset", SambaParmString, P_GLOBAL, "0"), - "LDAPDELETEDN" : ("ldap delete dn", SambaParmBool, P_GLOBAL, "No"), - "AFSSHARE" : ("afs share", SambaParmBool, P_LOCAL, "No"), - "ROOT" : ("root directory", SambaParmString, P_GLOBAL, ""), - "NAMERESOLVEORDER" : ("name resolve order", SambaParmString, P_GLOBAL, "lmhosts wins host bcast"), -} -##### end of smbparm.y ########################################## -################################################################# diff --git a/examples/scripts/shares/perl/modify_samba_config.pl b/examples/scripts/shares/perl/modify_samba_config.pl new file mode 100755 index 0000000000..ad958625d6 --- /dev/null +++ b/examples/scripts/shares/perl/modify_samba_config.pl @@ -0,0 +1,154 @@ +#!/usr/bin/perl + +## +## Simple example of how to implement a '[add|delete] share command' for +## use with the Windows NT Server Manager. See smb.conf(5) for details +## on the '[add|delete] share command' +## +## Author : Gerald (Jerry) Carter +## + +use POSIX qw(tmpnam); + +## +## local variables +## +my $delete_mode = undef; +my $add_mode = undef; +my $tmp_file_name = undef; + + +## check for correct parameters +if ($#ARGV == 1) { + $delete_mode = 1; +} +elsif ($#ARGV == 3) { + $add_mode = 1; +} +else { + print "Usage: $0 configfile share [path] [comment]\n"; + exit -1; +} + +## first param is always the config file +open (CONFIGFILE, "$ARGV[0]") || die "Unable to open $ARGV[0] for reading!\n"; + +## FIXME!! Right now we throw away all comments in the file. +while () { + + chomp($_); + + ## eat leading whitespace + $_ =~ s/^\s*//; + + ## eat trailing whitespace + $_ =~ s/\s*$//; + + + ## throw away comments + next if (($_ =~ /^#/) || ($_ =~ /^;/)); + + ## set the current section name for storing the hash + if ($_ =~ /^\[.*\]$/) { + + $_ = substr($_, 1, length($_)-2); + + if ( length($_) ) { + $section = $_; + } + else { + print "Bad Section Name - no closing ]\n"; + exit -1; + } + + next; + } + + ## check for a param = value + if ($_ =~ /=/) { + ($param, $value) = split (/=/, $_,2); + $param =~ s/./\l$&/g; + $param =~ s/\s+//g; + $value =~ s/^\s+//; + + $config{$section}{$param} = $value; + + next; + } + + ## should have a hash of hashes indexed by section name +} +close (CONFIGFILE); + +## +## We have the smb.conf in our hash of hashes now. +## Add or delete +## +if ($add_mode) { + $config{$ARGV[1]}{'path'} = $ARGV[2]; + $config{$ARGV[1]}{'comment'} = $ARGV[3]; +} +elsif ($delete_mode) { + delete $config{$ARGV[1]}; +} + +## +## Print the resulting configuration +## +#do { +# $tmp_file_name = tmpnam(); +# print "Using temporary file - $tmp_file_name\n"; +#} while (!sysopen(TMP, $tmp_file_name, O_RDWR|O_CREAT|O_EXCL)); +$tmp_file_name = tmpnam(); +open (TMP, ">$tmp_file_name") || die "Unable to open temporary file for writing!\n"; + +PrintConfigFile(TMP); + +## now overwrite the original config file +close (TMP); +system ("cp -pf $ARGV[0] $ARGV[0].bak"); +system ("cp -pf $tmp_file_name $ARGV[0]"); +unlink $tmp_file_name; + + +exit 0; + + + + + +####################################################################################### +## PrintConfigFile() +## +sub PrintConfigFile { + my ($output) = @_; + + ## print the file back out, beginning with the global section + print $output "#\n# Generated by $0\n#\n"; + + PrintSection ($output, 'global', $config{'global'}); + + foreach $section (keys %config) { + + if ("$section" ne "global") { + print $output "## Section - [$section]\n"; + PrintSection ($output, $section, $config{$section}); + } + } + + print $output "#\n# end of generated smb.conf\n#\n"; +} + +####################################################################################### +## PrintSection() +## +sub PrintSection { + my ($outfile, $name, $section) = @_; + + print $outfile "[$name]\n"; + foreach $param (keys %$section) { + print $outfile "\t$param".' 'x(25-length($param)). " = $$section{$param}\n"; + } + print $outfile "\n"; + +} diff --git a/examples/scripts/shares/python/SambaConfig.py b/examples/scripts/shares/python/SambaConfig.py new file mode 100644 index 0000000000..c70c23118a --- /dev/null +++ b/examples/scripts/shares/python/SambaConfig.py @@ -0,0 +1,315 @@ +import sys, string, SambaParm +from smbparm import parm_table + +###################################################################### +## +## smb.conf parser class +## +## Copyright (C) Gerald Carter 2004. +## +## 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., 675 Mass Ave, Cambridge, MA 02139, USA. +## +###################################################################### + + +##################################################################### +## multi line Samba comment +class SambaComment: + + def __init__( self, comment ): + self.comment = comment + + def Dump( self, stream, whitespace=None ): + if not self.comment: + return + for line in self.comment: + if whitespace: + stream.write( whitespace ) + stream.write( line ) + stream.write( "\n" ) + + +##################################################################### +## string smb.conf parms +class SambaParameter : + + ## indexs into the parm table tuples + DisplayName = 0 + ObjectType = 1 + DefaultValue = 2 + Scope = 3 + + ## Stores a key into the parm_table and creates an + ## SambaParmXXX object to store the value + def __init__( self, name, value, comment=None ): + self.key = string.upper(string.strip(name)) + self.comment = None + assert parm_table.has_key( self.key ), "Bad parameter name! [%s]" % name + self.parm = parm_table[self.key][self.ObjectType]( value ) + if comment : + self.comment = SambaComment( comment ) + + #if not self.parm.valid: + # self.parm.SetValue( parm_table[self.key][self.DefaultValue] ) + + ## simple test for global or service parameter scope + def isGlobalParm( self ) : + return parm_table[self.key][Scope] + + ## dump 1` character so setup the result + if not result: + result = "" + + ## Check for comments -- terminated by \n -- no continuation + + if input_str[0] == '#' or input_str[0] == ';' : + result = input_str + break + + ## check for line continuation + + if input_str[-1] == "\\" : + result += input_str[0:-1] + contine + + ## otherwise we have a complete line + result += input_str + break + + return result + + ## convert the parameter name to a form suitable as a dictionary key + def NormalizeParamName( self, param ): + return string.upper( string.join(string.split(param), "") ) + + ## Open the file and parse it into a services dictionary + ## if possible + def ReadConfig( self, filename ): + self.filename = filename + + try: + fconfig = open( filename, "r" ) + except IOError: + self.valid = False + return + + section_name = None + + ## the most recent seen comment is stored as an array + current_comment = [] + + while True: + + str = self.ReadLine( fconfig ) + if not str: + break + + ## Check for comments + if str[0] == '#' or str[0] == ';' : + current_comment.append( str ) + continue + + ## look for a next section name + if str[0]=='[' and str[-1]==']' : + section_name = str[1:-1] + self.AddService( section_name, current_comment ) + current_comment = [] + continue + + str_list = string.split( str, "=" ) + + if len(str_list) != 2 : + continue + + if not section_name : + print "parameter given without section name!" + break + + param = self.NormalizeParamName( str_list[0] ) + value = string.strip(str_list[1]) + + self.SetServiceOption( section_name, param, value, current_comment ) + self.dirty = False + + ## reset the comment strinf if we have one + current_comment = [] + + fconfig.close() + + ## Add a parameter to the global section + def SetGlobalOption( self, param, value, comment=None ) : + self.SetServiceOption( "GLOBAL", param, value, comment ) + + ## Add a parameter to a specific service + def SetServiceOption( self, servicename, param, value, comment=None ) : + service = string.upper(servicename) + parm = self.NormalizeParamName(param) + self.services[service]['_order_'].append( parm ) + self.services[service][parm] = SambaParameter( parm, value, comment ) + self.dirty = True + + ## remove a service from the config file + def DelService( self, servicename ) : + service = string.upper(servicename) + self.services[service] = None + self.dirty = True + + ## remove a service from the config file + def AddService( self, servicename, comment=None ) : + service = string.upper(servicename) + + self.services[service] = {} + self.services[service]['_order_'] = [] + + if ( comment ): + self.services[service]['_comment_'] = SambaComment( comment ) + + self.services_order.append( service ) + + self.dirty = True + + def isService( self, servicename ): + service = string.upper(servicename) + return self.services.has_key( service ) + + ## dump a single service to stream + def DumpService( self, stream, servicename ): + + ## comments first + if self.services[servicename].has_key( '_comment_' ): + self.services[servicename]['_comment_'].Dump( stream ) + + ## section header + stream.write( "[%s]\n" % (servicename) ) + + ## parameter = value + for parm in self.services[servicename]['_order_']: + self.services[servicename][parm].Dump(stream) + + ## dump the config to stream + def Dump( self, stream ): + self.DumpService( stream, "GLOBAL" ) + stream.write("\n") + + for section in self.services_order: + ## already handled the global section + if section == "GLOBAL": + continue + + ## check for deleted sections ## + if not self.services[section]: + continue + + self.DumpService( stream, section ) + stream.write( "\n" ) + + ## write out any changes to disk + def Flush( self ): + if not self.dirty: + return + + try: + fconfig = open( self.filename, "w" ) + except IOError: + sys.stderr.write( "ERROR!\n" ) + return 1 + + self.Dump( fconfig ) + fconfig.close() + return 0 + + def Services( self ): + service_list = [] + for section in self.services.keys(): + service_list.append( section ) + + return service_list + + def NumServices( self ): + return len(self.Services()) + + def Write( self, filename ): + self.filename = filename + self.valid = True + + if not self.dirty: + return + + self.Flush() + + + +###################################################################### +## Unit tests +###################################################################### + +if __name__ == "__main__" : + + x = SambaConf( ) + x.ReadConfig( sys.argv[1] ) + if not x.valid : + print "Bad file!" + sys.exit(1) + + x.Dump( sys.stdout ) + + + +## end of SambaConfig.py ###################################################### +############################################################################### + diff --git a/examples/scripts/shares/python/SambaParm.py b/examples/scripts/shares/python/SambaParm.py new file mode 100644 index 0000000000..292ad42cd2 --- /dev/null +++ b/examples/scripts/shares/python/SambaParm.py @@ -0,0 +1,84 @@ +###################################################################### +## +## smb.conf parameter classes +## +## Copyright (C) Gerald Carter 2004. +## +## 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., 675 Mass Ave, Cambridge, MA 02139, USA. +## +###################################################################### + +import string + +##################################################################### +## Base class for Samba smb.conf parameters +class SambaParm : + def __init__( self ) : + pass + + def StringValue( self ) : + return self.value + +##################################################################### +## Boolean smb,conf parm +class SambaParmBool( SambaParm ): + def __init__( self, value ) : + x = string.upper(value) + self.valid = True + + if x=="YES" or x=="TRUE" or x=="1": + self.value = True + elif x=="NO" or x=="FALSE" or x=="0": + self.value = False + else: + self.valid = False + return self + + def SetValue( self, value ) : + x = string.upper(value) + self.valid = True + + if x=="YES" or x=="TRUE" or x=="1": + self.value = True + elif x=="NO" or x=="FALSE" or x=="0": + self.value = False + else: + self.valid = False + return + + def StringValue( self ) : + if self.value : + return "yes" + else: + return "no" + +##################################################################### +## Boolean smb,conf parm (inverts) +class SambaParmBoolRev( SambaParmBool ) : + def __init__( self, value ): + SambaParmBool.__init__( self, value ) + if self.valid : + self.value = not self.value + + +##################################################################### +## string smb.conf parms +class SambaParmString( SambaParm ): + def __init__( self, value ): + self.value = value + self.valid = True + + + diff --git a/examples/scripts/shares/python/generate_parm_table.py b/examples/scripts/shares/python/generate_parm_table.py new file mode 100755 index 0000000000..1dbc071e9b --- /dev/null +++ b/examples/scripts/shares/python/generate_parm_table.py @@ -0,0 +1,224 @@ +#!/usr/bin/env python +###################################################################### +## +## Generate parameter dictionary from param/loadparm.c +## +## Copyright (C) Gerald Carter 2004. +## +## 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., 675 Mass Ave, Cambridge, MA 02139, USA. +## +###################################################################### + +import re, string, sys, commands + +HEADER = """###################################################################### +## +## autogenerated file of smb.conf parameters +## generate_parm_table <..../param/loadparm.c> +## +## Copyright (C) Gerald Carter 2004. +## +## 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., 675 Mass Ave, Cambridge, MA 02139, USA. +## +###################################################################### + +from SambaParm import SambaParmString, SambaParmBool, SambaParmBoolRev + +## boolean defines for parm_table +P_LOCAL = 0 +P_GLOBAL = 1 + +""" + +FOOTER = """##### end of smbparm.y ########################################## +#################################################################""" + +TESTPARM = "/usr/bin/testparm" + +## fields in Samba's parameter table +displayName = 0 +type = 1 +scope = 2 +variable = 3 +flags = 6 + +parm_table = {} +var_table = {} +def_values = {} +obj_table = { + 'P_BOOL' : 'SambaParmBool', + 'P_BOOLREV' : 'SambaParmBoolRev', + 'P_STRING' : 'SambaParmString', + 'P_USTRING' : 'SambaParmString', + 'P_GSTRING' : 'SambaParmString', + 'P_LIST' : 'SambaParmString', + 'P_ENUM' : 'SambaParmString', + 'P_CHAR' : 'SambaParmString', + 'P_OCTAL' : 'SambaParmString', + 'P_INTEGER' : 'SambaParmString', +} + +###################################################################### +## BEGIN MAIN CODE ## +###################################################################### + +## First thing is to build the dictionary of parmeter names ## +## based on the output from testparm ## + +cmd = "/usr/bin/testparm -s -v /dev/null" +( status, testparm_output ) = commands.getstatusoutput( cmd ) +if status: + sys.stderr.write( "Failed to execute testparm!\n%s\n" % testparm_output ) + + +## break the output into a list ## + +lines = string.split( testparm_output, "\n" ) + +## loop through list -- parameters in testparm output have ## +## whitespace at the beginning of the line ## + +pattern = re.compile( "^\s+" ) +for input_str in lines: + if not pattern.search( input_str ): + continue + input_str = string.strip( input_str ) + parts = string.split( input_str, "=" ) + parts[0] = string.strip( parts[0] ) + parts[1] = string.strip( parts[1] ) + key = string.upper( string.join(string.split(parts[0]), "") ) + new = parts[1].replace('\\', '\\\\') + def_values[key] = new + +## open loadparm.c and get the entire list of parameters ## +## including synonums ## + +if len(sys.argv) != 2: + print "Usage: %s <.../param/loadparm.c>" % ( sys.argv[0] ) + sys.exit( 1 ) + +try: + fconfig = open( sys.argv[1], "r" ) +except IOError: + print "%s does not exist!" % sys.argv[1] + sys.exit (1) + +## Loop through loadparm.c -- all parameters are either ## +## P_LOCAL or P_GLOBAL ## + +synonyms = [] +pattern = re.compile( '{".*P_[GL]' ) +while True: + input_str= fconfig.readline() + if len(input_str) == 0 : + break + input_str= string.strip(input_str) + + ## see if we have a patch for a parameter definition ## + + parm = [] + if pattern.search( input_str) : + + ## strip the surrounding '{.*},' ## + + input_str= input_str[1:-2] + parm = string.split(input_str, ",") + + ## strip the ""'s and upper case ## + + name = (string.strip(parm[displayName])[1:-1]) + key = string.upper( string.join(string.split(name), "") ) + var_name = string.strip( parm[variable] ) + + + ## try to catch synonyms -- if the parameter was not reported ## + ## by testparm, then save it and come back after we will out ## + ## the variable list ## + + if not def_values.has_key( key ): + synonyms.append( input_str) + continue + + + var_table[var_name] = key + + parmType = string.strip(parm[type]) + + parm_table[key] = [ name , string.strip(parm[type]), string.strip(parm[scope]), def_values[key] ] + +## Deal with any synonyms ## + +for input_str in synonyms: + parm = string.split(input_str, ",") + name = (string.strip(parm[displayName])[1:-1]) + key = string.upper( string.join(string.split(name), "") ) + var_name = string.strip( parm[variable] ) + + ## if there's no pre-existing key, then testparm doesn't know about it + if not var_table.has_key( var_name ): + continue + + ## just make a copy + parm_table[key] = parm_table[var_table[var_name]][:] + # parm_table[key][1] = parm[1] + parm_table[key][1] = string.strip(parm[1]) + +## ## +## print out smbparm.py ## +## ## + +try: + smbparm = open ( "smbparm.py", "w" ) +except IOError: + print "Cannot write to smbparm.py" + sys.exit( 1 ) + +smbparm.write( HEADER ) +smbparm.write( "parm_table = {\n" ) + +for x in parm_table.keys(): + key = "\"%s\"" % x + smbparm.write("\t%-25s: (\"%s\", %s, %s, \"%s\"),\n" % ( key, parm_table[x][0], + obj_table[parm_table[x][1]], parm_table[x][2], parm_table[x][3] )) + +smbparm.write( "}\n" ) + +smbparm.write( FOOTER ) +smbparm.write( "\n" ) + +sys.exit(0) + + +## ## +## cut-n-paste area ## +## ## + +for x in parm_table.keys(): + if def_values.has_key( x ): + parm_table[x].append( def_values[x] ) + else: + parm_table[x].append( "" ) diff --git a/examples/scripts/shares/python/modify_samba_config.py b/examples/scripts/shares/python/modify_samba_config.py new file mode 100755 index 0000000000..6a4cdcab79 --- /dev/null +++ b/examples/scripts/shares/python/modify_samba_config.py @@ -0,0 +1,78 @@ +#!/usr/bin/env python +###################################################################### +## +## Simple add/delete/change share command script for Samba +## +## Copyright (C) Gerald Carter 2004. +## +## 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., 675 Mass Ave, Cambridge, MA 02139, USA. +## +###################################################################### + +import sys, os +from SambaConfig import SambaConf + + +## ## +## check the command line args ## +## ## +delete_mode = False +if len(sys.argv) == 3: + delete_mode = True + print "Deleting share..." +elif len(sys.argv) == 5: + print "Adding/Updating share..." +else: + print "Usage: %s configfile share [path] [comments]" % sys.argv[0] + sys.exit(1) + + +## ## +## read and parse the config file ## +## ## + +confFile = SambaConf() + +confFile.ReadConfig( sys.argv[1] ) +if not confFile.valid: + exit( 1 ) + +if delete_mode: + if not confFile.isService( sys.argv[2] ): + sys.stderr.write( "Asked to delete non-existent service! [%s]\n" % sys.argv[2] ) + sys.exit( 1 ) + + confFile.DelService( sys.argv[2] ) +else: + ## make the path if it doesn't exist. Bail out if that fails + if ( not os.path.isdir(sys.argv[3]) ): + try: + os.makedirs( sys.argv[3] ) + os.chmod( sys.argv[3], 0777 ) + except os.error: + sys.exit( 1 ) + + ## only add a new service -- if it already exists, then + ## just set the options + if not confFile.isService( sys.argv[2] ): + confFile.AddService( sys.argv[2], ['##', '## Added by modify_samba_config.py', '##'] ) + confFile.SetServiceOption( sys.argv[2], "path", sys.argv[3] ) + confFile.SetServiceOption( sys.argv[2], "comment", sys.argv[4] ) + confFile.SetServiceOption( sys.argv[2], "read only", "no" ) + +ret = confFile.Flush() + +sys.exit( ret ) + diff --git a/examples/scripts/shares/python/smbparm.py b/examples/scripts/shares/python/smbparm.py new file mode 100644 index 0000000000..0dfcf0062e --- /dev/null +++ b/examples/scripts/shares/python/smbparm.py @@ -0,0 +1,374 @@ +###################################################################### +## +## autogenerated file of smb.conf parameters +## generate_parm_table <..../param/loadparm.c> +## +## Copyright (C) Gerald Carter 2004. +## +## 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., 675 Mass Ave, Cambridge, MA 02139, USA. +## +###################################################################### + +from SambaParm import SambaParmString, SambaParmBool, SambaParmBoolRev + +## boolean defines for parm_table +P_LOCAL = 0 +P_GLOBAL = 1 + +parm_table = { + "PRELOADMODULES" : ("preload modules", SambaParmString, P_GLOBAL, ""), + "ONLYGUEST" : ("guest only", SambaParmBool, P_LOCAL, "No"), + "PRIVATEDIR" : ("private dir", SambaParmString, P_GLOBAL, "/etc/samba/private"), + "HIDESPECIALFILES" : ("hide special files", SambaParmBool, P_LOCAL, "No"), + "WINBINDENUMUSERS" : ("winbind enum users", SambaParmBool, P_GLOBAL, "Yes"), + "TIMESTAMPLOGS" : ("debug timestamp", SambaParmBool, P_GLOBAL, "Yes"), + "LDAPPASSWDSYNC" : ("ldap passwd sync", SambaParmString, P_GLOBAL, "no"), + "READBMPX" : ("read bmpx", SambaParmBool, P_GLOBAL, "No"), + "PASSWORDSERVER" : ("password server", SambaParmString, P_GLOBAL, "*"), + "COPY" : ("copy", SambaParmString, P_LOCAL, ""), + "MAXXMIT" : ("max xmit", SambaParmString, P_GLOBAL, "16644"), + "MINPRINTSPACE" : ("min print space", SambaParmString, P_LOCAL, "0"), + "CASESENSITIVE" : ("case sensitive", SambaParmString, P_LOCAL, "Auto"), + "LDAPIDMAPSUFFIX" : ("ldap idmap suffix", SambaParmString, P_GLOBAL, ""), + "NAMECACHETIMEOUT" : ("name cache timeout", SambaParmString, P_GLOBAL, "660"), + "MAPARCHIVE" : ("map archive", SambaParmBool, P_LOCAL, "Yes"), + "LANMANAUTH" : ("lanman auth", SambaParmBool, P_GLOBAL, "Yes"), + "NETBIOSSCOPE" : ("netbios scope", SambaParmString, P_GLOBAL, ""), + "MAXREPORTEDPRINTJOBS" : ("max reported print jobs", SambaParmString, P_LOCAL, "0"), + "CREATEMODE" : ("create mask", SambaParmString, P_LOCAL, "0744"), + "READLIST" : ("read list", SambaParmString, P_LOCAL, ""), + "WINBINDNESTEDGROUPS" : ("winbind nested groups", SambaParmBool, P_GLOBAL, "No"), + "COMMENT" : ("comment", SambaParmString, P_LOCAL, ""), + "PRINTER" : ("printer name", SambaParmString, P_LOCAL, ""), + "LMANNOUNCE" : ("lm announce", SambaParmString, P_GLOBAL, "Auto"), + "SYSLOGONLY" : ("syslog only", SambaParmBool, P_GLOBAL, "No"), + "LMINTERVAL" : ("lm interval", SambaParmString, P_GLOBAL, "60"), + "MANGLINGMETHOD" : ("mangling method", SambaParmString, P_GLOBAL, "hash2"), + "PROFILEACLS" : ("profile acls", SambaParmBool, P_LOCAL, "No"), + "LDAPGROUPSUFFIX" : ("ldap group suffix", SambaParmString, P_GLOBAL, ""), + "MAPTOGUEST" : ("map to guest", SambaParmString, P_GLOBAL, "Never"), + "NULLPASSWORDS" : ("null passwords", SambaParmBool, P_GLOBAL, "No"), + "ONLYUSER" : ("only user", SambaParmBool, P_LOCAL, "No"), + "UTMP" : ("utmp", SambaParmBool, P_GLOBAL, "No"), + "DONTDESCEND" : ("dont descend", SambaParmString, P_LOCAL, ""), + "PRINTING" : ("printing", SambaParmString, P_LOCAL, "cups"), + "SOCKETOPTIONS" : ("socket options", SambaParmString, P_GLOBAL, "TCP_NODELAY"), + "CLIENTUSESPNEGO" : ("client use spnego", SambaParmBool, P_GLOBAL, "Yes"), + "USESPNEGO" : ("use spnego", SambaParmBool, P_GLOBAL, "Yes"), + "FAKEOPLOCKS" : ("fake oplocks", SambaParmBool, P_LOCAL, "No"), + "FORCECREATEMODE" : ("force create mode", SambaParmString, P_LOCAL, "00"), + "SETDIRECTORY" : ("set directory", SambaParmBoolRev, P_LOCAL, "No"), + "SMBPORTS" : ("smb ports", SambaParmString, P_GLOBAL, "445 139"), + "LOCKDIR" : ("lock directory", SambaParmString, P_GLOBAL, "/var/lib/samba"), + "BROWSEABLE" : ("browseable", SambaParmBool, P_LOCAL, "Yes"), + "WINSPROXY" : ("wins proxy", SambaParmBool, P_GLOBAL, "No"), + "FORCEGROUP" : ("force group", SambaParmString, P_LOCAL, ""), + "NTSTATUSSUPPORT" : ("nt status support", SambaParmBool, P_GLOBAL, "Yes"), + "EXEC" : ("preexec", SambaParmString, P_LOCAL, ""), + "DOMAINLOGONS" : ("domain logons", SambaParmBool, P_GLOBAL, "No"), + "TEMPLATESHELL" : ("template shell", SambaParmString, P_GLOBAL, "/bin/false"), + "USESENDFILE" : ("use sendfile", SambaParmBool, P_LOCAL, "No"), + "USEMMAP" : ("use mmap", SambaParmBool, P_GLOBAL, "Yes"), + "VALIDUSERS" : ("valid users", SambaParmString, P_LOCAL, ""), + "DEBUGLEVEL" : ("log level", SambaParmString, P_GLOBAL, "0"), + "PRINTCAPCACHETIME" : ("printcap cache time", SambaParmString, P_GLOBAL, "0"), + "SOCKETADDRESS" : ("socket address", SambaParmString, P_GLOBAL, "0.0.0.0"), + "FORCEDIRECTORYMODE" : ("force directory mode", SambaParmString, P_LOCAL, "00"), + "MSDFSROOT" : ("msdfs root", SambaParmBool, P_LOCAL, "No"), + "ROOTPREEXEC" : ("root preexec", SambaParmString, P_LOCAL, ""), + "WRITEOK" : ("read only", SambaParmBoolRev, P_LOCAL, "Yes"), + "MAXLOGSIZE" : ("max log size", SambaParmString, P_GLOBAL, "5000"), + "FORCESECURITYMODE" : ("force security mode", SambaParmString, P_LOCAL, "00"), + "VFSOBJECT" : ("vfs objects", SambaParmString, P_LOCAL, ""), + "CHECKPASSWORDSCRIPT" : ("check password script", SambaParmString, P_GLOBAL, ""), + "DELETEPRINTERCOMMAND" : ("deleteprinter command", SambaParmString, P_GLOBAL, ""), + "OSLEVEL" : ("os level", SambaParmString, P_GLOBAL, "20"), + "ENUMPORTSCOMMAND" : ("enumports command", SambaParmString, P_GLOBAL, ""), + "DELETEUSERFROMGROUPSCRIPT": ("delete user from group script", SambaParmString, P_GLOBAL, ""), + "IDMAPGID" : ("idmap gid", SambaParmString, P_GLOBAL, ""), + "PREEXECCLOSE" : ("preexec close", SambaParmBool, P_LOCAL, "No"), + "UTMPDIRECTORY" : ("utmp directory", SambaParmString, P_GLOBAL, ""), + "DOSFILEMODE" : ("dos filemode", SambaParmBool, P_LOCAL, "No"), + "LOGFILE" : ("log file", SambaParmString, P_GLOBAL, ""), + "WORKGROUP" : ("workgroup", SambaParmString, P_GLOBAL, "WORKGROUP"), + "DIRECTORYSECURITYMASK" : ("directory security mask", SambaParmString, P_LOCAL, "0777"), + "ENCRYPTPASSWORDS" : ("encrypt passwords", SambaParmBool, P_GLOBAL, "Yes"), + "PRINTABLE" : ("printable", SambaParmBool, P_LOCAL, "No"), + "MAXPROTOCOL" : ("max protocol", SambaParmString, P_GLOBAL, "NT1"), + "KERNELOPLOCKS" : ("kernel oplocks", SambaParmBool, P_GLOBAL, "Yes"), + "NETBIOSALIASES" : ("netbios aliases", SambaParmString, P_GLOBAL, ""), + "ANNOUNCEAS" : ("announce as", SambaParmString, P_GLOBAL, "NT"), + "DIRECTORYMASK" : ("directory mask", SambaParmString, P_LOCAL, "0755"), + "MAPSYSTEM" : ("map system", SambaParmBool, P_LOCAL, "No"), + "CHANGENOTIFYTIMEOUT" : ("change notify timeout", SambaParmString, P_GLOBAL, "60"), + "WINBINDTRUSTEDDOMAINSONLY": ("winbind trusted domains only", SambaParmBool, P_GLOBAL, "No"), + "SHUTDOWNSCRIPT" : ("shutdown script", SambaParmString, P_GLOBAL, ""), + "FOLLOWSYMLINKS" : ("follow symlinks", SambaParmBool, P_LOCAL, "Yes"), + "MAPHIDDEN" : ("map hidden", SambaParmBool, P_LOCAL, "No"), + "GROUP" : ("force group", SambaParmString, P_LOCAL, ""), + "DENYHOSTS" : ("hosts deny", SambaParmString, P_LOCAL, ""), + "WINBINDCACHETIME" : ("winbind cache time", SambaParmString, P_GLOBAL, "300"), + "DELETEVETOFILES" : ("delete veto files", SambaParmBool, P_LOCAL, "No"), + "DISABLESPOOLSS" : ("disable spoolss", SambaParmBool, P_GLOBAL, "No"), + "MAXCONNECTIONS" : ("max connections", SambaParmString, P_LOCAL, "0"), + "WRITERAW" : ("write raw", SambaParmBool, P_GLOBAL, "Yes"), + "SERVERSIGNING" : ("server signing", SambaParmString, P_GLOBAL, "No"), + "VOLUME" : ("volume", SambaParmString, P_LOCAL, ""), + "UNIXPASSWORDSYNC" : ("unix password sync", SambaParmBool, P_GLOBAL, "No"), + "OBEYPAMRESTRICTIONS" : ("obey pam restrictions", SambaParmBool, P_GLOBAL, "No"), + "PASSWDCHATTIMEOUT" : ("passwd chat timeout", SambaParmString, P_GLOBAL, "2"), + "USER" : ("username", SambaParmString, P_LOCAL, ""), + "HIDEDOTFILES" : ("hide dot files", SambaParmBool, P_LOCAL, "Yes"), + "ROOTPOSTEXEC" : ("root postexec", SambaParmString, P_LOCAL, ""), + "PROTOCOL" : ("max protocol", SambaParmString, P_GLOBAL, "NT1"), + "LDAPADMINDN" : ("ldap admin dn", SambaParmString, P_GLOBAL, ""), + "DNSPROXY" : ("dns proxy", SambaParmBool, P_GLOBAL, "Yes"), + "OS2DRIVERMAP" : ("os2 driver map", SambaParmString, P_GLOBAL, ""), + "QUEUERESUMECOMMAND" : ("queueresume command", SambaParmString, P_LOCAL, ""), + "SERVERSCHANNEL" : ("server schannel", SambaParmString, P_GLOBAL, "Auto"), + "IDMAPUID" : ("idmap uid", SambaParmString, P_GLOBAL, ""), + "WINBINDENABLELOCALACCOUNTS": ("winbind enable local accounts", SambaParmBool, P_GLOBAL, "No"), + "PRINTERNAME" : ("printer name", SambaParmString, P_LOCAL, ""), + "NTACLSUPPORT" : ("nt acl support", SambaParmBool, P_LOCAL, "Yes"), + "LOGLEVEL" : ("log level", SambaParmString, P_GLOBAL, "0"), + "STATCACHE" : ("stat cache", SambaParmBool, P_GLOBAL, "Yes"), + "LPQCACHETIME" : ("lpq cache time", SambaParmString, P_GLOBAL, "30"), + "LEVEL2OPLOCKS" : ("level2 oplocks", SambaParmBool, P_LOCAL, "Yes"), + "LARGEREADWRITE" : ("large readwrite", SambaParmBool, P_GLOBAL, "Yes"), + "LDAPREPLICATIONSLEEP" : ("ldap replication sleep", SambaParmString, P_GLOBAL, "1000"), + "SECURITYMASK" : ("security mask", SambaParmString, P_LOCAL, "0777"), + "LDAPUSERSUFFIX" : ("ldap user suffix", SambaParmString, P_GLOBAL, ""), + "NETBIOSNAME" : ("netbios name", SambaParmString, P_GLOBAL, "PANTHER"), + "LOCKSPINCOUNT" : ("lock spin count", SambaParmString, P_GLOBAL, "3"), + "OPLOCKS" : ("oplocks", SambaParmBool, P_LOCAL, "Yes"), + "MINWINSTTL" : ("min wins ttl", SambaParmString, P_GLOBAL, "21600"), + "HOMEDIRMAP" : ("homedir map", SambaParmString, P_GLOBAL, ""), + "REMOTEANNOUNCE" : ("remote announce", SambaParmString, P_GLOBAL, ""), + "PREFERREDMASTER" : ("preferred master", SambaParmString, P_GLOBAL, "Auto"), + "SECURITY" : ("security", SambaParmString, P_GLOBAL, "USER"), + "AUTHMETHODS" : ("auth methods", SambaParmString, P_GLOBAL, ""), + "ENABLERIDALGORITHM" : ("enable rid algorithm", SambaParmBool, P_GLOBAL, "Yes"), + "LPRMCOMMAND" : ("lprm command", SambaParmString, P_LOCAL, ""), + "KERNELCHANGENOTIFY" : ("kernel change notify", SambaParmBool, P_GLOBAL, "Yes"), + "LOGONSCRIPT" : ("logon script", SambaParmString, P_GLOBAL, ""), + "PRESERVECASE" : ("preserve case", SambaParmBool, P_LOCAL, "Yes"), + "UNIXCHARSET" : ("unix charset", SambaParmString, P_GLOBAL, "UTF-8"), + "FORCEPRINTERNAME" : ("force printername", SambaParmBool, P_LOCAL, "No"), + "LDAPFILTER" : ("ldap filter", SambaParmString, P_GLOBAL, "(uid"), + "DELETEREADONLY" : ("delete readonly", SambaParmBool, P_LOCAL, "No"), + "ABORTSHUTDOWNSCRIPT" : ("abort shutdown script", SambaParmString, P_GLOBAL, ""), + "DFREECOMMAND" : ("dfree command", SambaParmString, P_GLOBAL, ""), + "VETOFILES" : ("veto files", SambaParmString, P_LOCAL, ""), + "LOCKING" : ("locking", SambaParmBool, P_LOCAL, "Yes"), + "EASUPPORT" : ("ea support", SambaParmBool, P_LOCAL, "No"), + "MAXSMBDPROCESSES" : ("max smbd processes", SambaParmString, P_GLOBAL, "0"), + "HIDEFILES" : ("hide files", SambaParmString, P_LOCAL, ""), + "PASSWDCHATDEBUG" : ("passwd chat debug", SambaParmBool, P_GLOBAL, "No"), + "SMBPASSWDFILE" : ("smb passwd file", SambaParmString, P_GLOBAL, "/etc/samba/private/smbpasswd"), + "GETQUOTACOMMAND" : ("get quota command", SambaParmString, P_GLOBAL, ""), + "OPLOCKCONTENTIONLIMIT" : ("oplock contention limit", SambaParmString, P_LOCAL, "2"), + "DOMAINMASTER" : ("domain master", SambaParmString, P_GLOBAL, "Auto"), + "DELETESHARECOMMAND" : ("delete share command", SambaParmString, P_GLOBAL, ""), + "INVALIDUSERS" : ("invalid users", SambaParmString, P_LOCAL, ""), + "POSIXLOCKING" : ("posix locking", SambaParmBool, P_LOCAL, "Yes"), + "INCLUDE" : ("include", SambaParmString, P_LOCAL, ""), + "ALGORITHMICRIDBASE" : ("algorithmic rid base", SambaParmString, P_GLOBAL, "1000"), + "FORCEDIRECTORYSECURITYMODE": ("force directory security mode", SambaParmString, P_LOCAL, "00"), + "ANNOUNCEVERSION" : ("announce version", SambaParmString, P_GLOBAL, "4.9"), + "USERNAMEMAP" : ("username map", SambaParmString, P_GLOBAL, ""), + "MANGLEDNAMES" : ("mangled names", SambaParmBool, P_LOCAL, "Yes"), + "ROOTDIRECTORY" : ("root directory", SambaParmString, P_GLOBAL, ""), + "DEBUGHIRESTIMESTAMP" : ("debug hires timestamp", SambaParmBool, P_GLOBAL, "No"), + "LOGONDRIVE" : ("logon drive", SambaParmString, P_GLOBAL, ""), + "LOCALMASTER" : ("local master", SambaParmBool, P_GLOBAL, "Yes"), + "ROOTPREEXECCLOSE" : ("root preexec close", SambaParmBool, P_LOCAL, "No"), + "CONFIGFILE" : ("config file", SambaParmString, P_GLOBAL, ""), + "USECLIENTDRIVER" : ("use client driver", SambaParmBool, P_LOCAL, "No"), + "MINPROTOCOL" : ("min protocol", SambaParmString, P_GLOBAL, "CORE"), + "ADDUSERTOGROUPSCRIPT" : ("add user to group script", SambaParmString, P_GLOBAL, ""), + "MAPACLINHERIT" : ("map acl inherit", SambaParmBool, P_LOCAL, "No"), + "DELETEUSERSCRIPT" : ("delete user script", SambaParmString, P_GLOBAL, ""), + "WINBINDUID" : ("idmap uid", SambaParmString, P_GLOBAL, ""), + "READRAW" : ("read raw", SambaParmBool, P_GLOBAL, "Yes"), + "WINBINDENUMGROUPS" : ("winbind enum groups", SambaParmBool, P_GLOBAL, "Yes"), + "PASSWORDLEVEL" : ("password level", SambaParmString, P_GLOBAL, "0"), + "MAXPRINTJOBS" : ("max print jobs", SambaParmString, P_LOCAL, "1000"), + "PRINTCAP" : ("printcap name", SambaParmString, P_GLOBAL, ""), + "LOADPRINTERS" : ("load printers", SambaParmBool, P_GLOBAL, "Yes"), + "DEFAULT" : ("default service", SambaParmString, P_GLOBAL, ""), + "GUESTACCOUNT" : ("guest account", SambaParmString, P_GLOBAL, "nobody"), + "AUTOSERVICES" : ("preload", SambaParmString, P_GLOBAL, ""), + "WRITEABLE" : ("read only", SambaParmBoolRev, P_LOCAL, "Yes"), + "CLIENTLANMANAUTH" : ("client lanman auth", SambaParmBool, P_GLOBAL, "Yes"), + "MESSAGECOMMAND" : ("message command", SambaParmString, P_GLOBAL, ""), + "UNIXEXTENSIONS" : ("unix extensions", SambaParmBool, P_GLOBAL, "Yes"), + "LDAPPASSWORDSYNC" : ("ldap passwd sync", SambaParmString, P_GLOBAL, "no"), + "AFSUSERNAMEMAP" : ("afs username map", SambaParmString, P_GLOBAL, ""), + "SYSLOG" : ("syslog", SambaParmString, P_GLOBAL, "1"), + "SETPRIMARYGROUPSCRIPT" : ("set primary group script", SambaParmString, P_GLOBAL, ""), + "DEADTIME" : ("deadtime", SambaParmString, P_GLOBAL, "0"), + "RESTRICTANONYMOUS" : ("restrict anonymous", SambaParmString, P_GLOBAL, "0"), + "USERNAMELEVEL" : ("username level", SambaParmString, P_GLOBAL, "0"), + "DISPLAYCHARSET" : ("display charset", SambaParmString, P_GLOBAL, "LOCALE"), + "FORCEUSER" : ("force user", SambaParmString, P_LOCAL, ""), + "HOSTSDENY" : ("hosts deny", SambaParmString, P_LOCAL, ""), + "HIDEUNWRITEABLEFILES" : ("hide unwriteable files", SambaParmBool, P_LOCAL, "No"), + "DOSCHARSET" : ("dos charset", SambaParmString, P_GLOBAL, "CP850"), + "DOSFILETIMES" : ("dos filetimes", SambaParmBool, P_LOCAL, "No"), + "REALM" : ("realm", SambaParmString, P_GLOBAL, ""), + "LDAPSUFFIX" : ("ldap suffix", SambaParmString, P_GLOBAL, ""), + "LPPAUSECOMMAND" : ("lppause command", SambaParmString, P_LOCAL, ""), + "FAKEDIRECTORYCREATETIMES": ("fake directory create times", SambaParmBool, P_LOCAL, "No"), + "MAGICSCRIPT" : ("magic script", SambaParmString, P_LOCAL, ""), + "WRITECACHESIZE" : ("write cache size", SambaParmString, P_LOCAL, "0"), + "BLOCKSIZE" : ("block size", SambaParmString, P_LOCAL, "1024"), + "LOCKSPINTIME" : ("lock spin time", SambaParmString, P_GLOBAL, "10"), + "ACLCOMPATIBILITY" : ("acl compatibility", SambaParmString, P_GLOBAL, ""), + "MSDFSPROXY" : ("msdfs proxy", SambaParmString, P_LOCAL, ""), + "POSTEXEC" : ("postexec", SambaParmString, P_LOCAL, ""), + "HIDEUNREADABLE" : ("hide unreadable", SambaParmBool, P_LOCAL, "No"), + "WIDELINKS" : ("wide links", SambaParmBool, P_LOCAL, "Yes"), + "STRICTSYNC" : ("strict sync", SambaParmBool, P_LOCAL, "No"), + "PRINTCAPNAME" : ("printcap name", SambaParmString, P_GLOBAL, ""), + "PREFEREDMASTER" : ("preferred master", SambaParmString, P_GLOBAL, "Auto"), + "MAXMUX" : ("max mux", SambaParmString, P_GLOBAL, "50"), + "VETOOPLOCKFILES" : ("veto oplock files", SambaParmString, P_LOCAL, ""), + "WINBINDSEPARATOR" : ("winbind separator", SambaParmString, P_GLOBAL, "\\"), + "NISHOMEDIR" : ("NIS homedir", SambaParmBool, P_GLOBAL, "No"), + "AVAILABLE" : ("available", SambaParmBool, P_LOCAL, "Yes"), + "KEEPALIVE" : ("keepalive", SambaParmString, P_GLOBAL, "300"), + "USERNAME" : ("username", SambaParmString, P_LOCAL, ""), + "PRINTCOMMAND" : ("print command", SambaParmString, P_LOCAL, ""), + "LPRESUMECOMMAND" : ("lpresume command", SambaParmString, P_LOCAL, ""), + "USEKERBEROSKEYTAB" : ("use kerberos keytab", SambaParmBool, P_GLOBAL, "No"), + "HOSTSALLOW" : ("hosts allow", SambaParmString, P_LOCAL, ""), + "MAXOPENFILES" : ("max open files", SambaParmString, P_GLOBAL, "10000"), + "PARANOIDSERVERSECURITY" : ("paranoid server security", SambaParmBool, P_GLOBAL, "Yes"), + "WTMPDIRECTORY" : ("wtmp directory", SambaParmString, P_GLOBAL, ""), + "ADDPRINTERCOMMAND" : ("addprinter command", SambaParmString, P_GLOBAL, ""), + "PRINTERADMIN" : ("printer admin", SambaParmString, P_LOCAL, ""), + "WINSSERVER" : ("wins server", SambaParmString, P_GLOBAL, ""), + "LDAPTIMEOUT" : ("ldap timeout", SambaParmString, P_GLOBAL, "15"), + "LOCKDIRECTORY" : ("lock directory", SambaParmString, P_GLOBAL, "/var/lib/samba"), + "LOGONHOME" : ("logon home", SambaParmString, P_GLOBAL, "\\%N\%U"), + "MINPASSWDLENGTH" : ("min password length", SambaParmString, P_GLOBAL, "5"), + "CLIENTPLAINTEXTAUTH" : ("client plaintext auth", SambaParmBool, P_GLOBAL, "Yes"), + "CSCPOLICY" : ("csc policy", SambaParmString, P_LOCAL, "manual"), + "ADDSHARECOMMAND" : ("add share command", SambaParmString, P_GLOBAL, ""), + "MANGLINGCHAR" : ("mangling char", SambaParmString, P_LOCAL, "~"), + "DIRECTORY" : ("path", SambaParmString, P_LOCAL, ""), + "DEBUGTIMESTAMP" : ("debug timestamp", SambaParmBool, P_GLOBAL, "Yes"), + "ALLOWHOSTS" : ("hosts allow", SambaParmString, P_LOCAL, ""), + "FSTYPE" : ("fstype", SambaParmString, P_LOCAL, "NTFS"), + "BLOCKINGLOCKS" : ("blocking locks", SambaParmBool, P_LOCAL, "Yes"), + "LDAPSSL" : ("ldap ssl", SambaParmString, P_GLOBAL, ""), + "PAMPASSWORDCHANGE" : ("pam password change", SambaParmBool, P_GLOBAL, "No"), + "GUESTOK" : ("guest ok", SambaParmBool, P_LOCAL, "No"), + "DEFAULTDEVMODE" : ("default devmode", SambaParmBool, P_LOCAL, "No"), + "MAXDISKSIZE" : ("max disk size", SambaParmString, P_GLOBAL, "0"), + "ADDMACHINESCRIPT" : ("add machine script", SambaParmString, P_GLOBAL, ""), + "MANGLEPREFIX" : ("mangle prefix", SambaParmString, P_GLOBAL, "1"), + "DISABLENETBIOS" : ("disable netbios", SambaParmBool, P_GLOBAL, "No"), + "LOGONPATH" : ("logon path", SambaParmString, P_GLOBAL, "\\%N\%U\profile"), + "IDMAPBACKEND" : ("idmap backend", SambaParmString, P_GLOBAL, ""), + "SHORTPRESERVECASE" : ("short preserve case", SambaParmBool, P_LOCAL, "Yes"), + "CUPSSERVER" : ("cups server", SambaParmString, P_GLOBAL, ""), + "NTPIPESUPPORT" : ("nt pipe support", SambaParmBool, P_GLOBAL, "Yes"), + "READONLY" : ("read only", SambaParmBool, P_LOCAL, "Yes"), + "MACHINEPASSWORDTIMEOUT" : ("machine password timeout", SambaParmString, P_GLOBAL, "604800"), + "PIDDIRECTORY" : ("pid directory", SambaParmString, P_GLOBAL, "/var/run"), + "PUBLIC" : ("guest ok", SambaParmBool, P_LOCAL, "No"), + "DEBUGPID" : ("debug pid", SambaParmBool, P_GLOBAL, "No"), + "GUESTONLY" : ("guest only", SambaParmBool, P_LOCAL, "No"), + "DELETEGROUPSCRIPT" : ("delete group script", SambaParmString, P_GLOBAL, ""), + "CUPSOPTIONS" : ("cups options", SambaParmString, P_LOCAL, ""), + "PASSWDCHAT" : ("passwd chat", SambaParmString, P_GLOBAL, "*new*password* %n\n *new*password* %n\n *changed*"), + "STRICTLOCKING" : ("strict locking", SambaParmString, P_LOCAL, "Yes"), + "TEMPLATEHOMEDIR" : ("template homedir", SambaParmString, P_GLOBAL, "/home/%D/%U"), + "WINBINDGID" : ("idmap gid", SambaParmString, P_GLOBAL, ""), + "INHERITPERMISSIONS" : ("inherit permissions", SambaParmBool, P_LOCAL, "No"), + "TIMESERVER" : ("time server", SambaParmBool, P_GLOBAL, "No"), + "BROWSELIST" : ("browse list", SambaParmBool, P_GLOBAL, "Yes"), + "HOSTNAMELOOKUPS" : ("hostname lookups", SambaParmBool, P_GLOBAL, "No"), + "DOSFILETIMERESOLUTION" : ("dos filetime resolution", SambaParmBool, P_LOCAL, "No"), + "CREATEMASK" : ("create mask", SambaParmString, P_LOCAL, "0744"), + "WINSHOOK" : ("wins hook", SambaParmString, P_GLOBAL, ""), + "DEFAULTCASE" : ("default case", SambaParmString, P_LOCAL, "lower"), + "PATH" : ("path", SambaParmString, P_LOCAL, ""), + "SHOWADDPRINTERWIZARD" : ("show add printer wizard", SambaParmBool, P_GLOBAL, "Yes"), + "WINSPARTNERS" : ("wins partners", SambaParmString, P_GLOBAL, ""), + "ENABLEPRIVILEGES" : ("enable privileges", SambaParmBool, P_GLOBAL, "No"), + "VFSOBJECTS" : ("vfs objects", SambaParmString, P_LOCAL, ""), + "STRICTALLOCATE" : ("strict allocate", SambaParmBool, P_LOCAL, "No"), + "PREEXEC" : ("preexec", SambaParmString, P_LOCAL, ""), + "WINSSUPPORT" : ("wins support", SambaParmBool, P_GLOBAL, "No"), + "HOSTMSDFS" : ("host msdfs", SambaParmBool, P_GLOBAL, "No"), + "AFSTOKENLIFETIME" : ("afs token lifetime", SambaParmString, P_GLOBAL, "604800"), + "PRINTOK" : ("printable", SambaParmBool, P_LOCAL, "No"), + "TEMPLATEPRIMARYGROUP" : ("template primary group", SambaParmString, P_GLOBAL, "nobody"), + "PASSWDPROGRAM" : ("passwd program", SambaParmString, P_GLOBAL, ""), + "SYNCALWAYS" : ("sync always", SambaParmBool, P_LOCAL, "No"), + "QUEUEPAUSECOMMAND" : ("queuepause command", SambaParmString, P_LOCAL, ""), + "BINDINTERFACESONLY" : ("bind interfaces only", SambaParmBool, P_GLOBAL, "No"), + "MAXWINSTTL" : ("max wins ttl", SambaParmString, P_GLOBAL, "518400"), + "GETWDCACHE" : ("getwd cache", SambaParmBool, P_GLOBAL, "Yes"), + "MAGICOUTPUT" : ("magic output", SambaParmString, P_LOCAL, ""), + "ADMINUSERS" : ("admin users", SambaParmString, P_LOCAL, ""), + "DIRECTORYMODE" : ("directory mask", SambaParmString, P_LOCAL, "0755"), + "CLIENTSIGNING" : ("client signing", SambaParmString, P_GLOBAL, "auto"), + "PASSDBBACKEND" : ("passdb backend", SambaParmString, P_GLOBAL, "smbpasswd"), + "CASESIGNAMES" : ("case sensitive", SambaParmString, P_LOCAL, "Auto"), + "SETQUOTACOMMAND" : ("set quota command", SambaParmString, P_GLOBAL, ""), + "LPQCOMMAND" : ("lpq command", SambaParmString, P_LOCAL, ""), + "SERVERSTRING" : ("server string", SambaParmString, P_GLOBAL, "Samba 3.0.11pre2-SVN-build-4840"), + "DEFAULTSERVICE" : ("default service", SambaParmString, P_GLOBAL, ""), + "WINBINDUSEDEFAULTDOMAIN": ("winbind use default domain", SambaParmBool, P_GLOBAL, "No"), + "INTERFACES" : ("interfaces", SambaParmString, P_GLOBAL, ""), + "ROOTDIR" : ("root directory", SambaParmString, P_GLOBAL, ""), + "ADDUSERSCRIPT" : ("add user script", SambaParmString, P_GLOBAL, ""), + "CLIENTNTLMV2AUTH" : ("client NTLMv2 auth", SambaParmBool, P_GLOBAL, "No"), + "FORCEUNKNOWNACLUSER" : ("force unknown acl user", SambaParmBool, P_LOCAL, "No"), + "MANGLEDMAP" : ("mangled map", SambaParmString, P_LOCAL, ""), + "NTLMAUTH" : ("ntlm auth", SambaParmBool, P_GLOBAL, "Yes"), + "INHERITACLS" : ("inherit acls", SambaParmBool, P_LOCAL, "No"), + "HOSTSEQUIV" : ("hosts equiv", SambaParmString, P_GLOBAL, ""), + "ALLOWTRUSTEDDOMAINS" : ("allow trusted domains", SambaParmBool, P_GLOBAL, "Yes"), + "MINPASSWORDLENGTH" : ("min password length", SambaParmString, P_GLOBAL, "5"), + "USERS" : ("username", SambaParmString, P_LOCAL, ""), + "PRELOAD" : ("preload", SambaParmString, P_GLOBAL, ""), + "DEBUGUID" : ("debug uid", SambaParmBool, P_GLOBAL, "No"), + "CHANGESHARECOMMAND" : ("change share command", SambaParmString, P_GLOBAL, ""), + "BROWSABLE" : ("browseable", SambaParmBool, P_LOCAL, "Yes"), + "ENHANCEDBROWSING" : ("enhanced browsing", SambaParmBool, P_GLOBAL, "Yes"), + "PANICACTION" : ("panic action", SambaParmString, P_GLOBAL, ""), + "LDAPMACHINESUFFIX" : ("ldap machine suffix", SambaParmString, P_GLOBAL, ""), + "UPDATEENCRYPTED" : ("update encrypted", SambaParmBool, P_GLOBAL, "No"), + "MAXTTL" : ("max ttl", SambaParmString, P_GLOBAL, "259200"), + "WRITABLE" : ("read only", SambaParmBoolRev, P_LOCAL, "Yes"), + "SHAREMODES" : ("share modes", SambaParmBool, P_LOCAL, "Yes"), + "REMOTEBROWSESYNC" : ("remote browse sync", SambaParmString, P_GLOBAL, ""), + "STOREDOSATTRIBUTES" : ("store dos attributes", SambaParmBool, P_LOCAL, "No"), + "CLIENTSCHANNEL" : ("client schannel", SambaParmString, P_GLOBAL, "Auto"), + "WRITELIST" : ("write list", SambaParmString, P_LOCAL, ""), + "ADDGROUPSCRIPT" : ("add group script", SambaParmString, P_GLOBAL, ""), + "OPLOCKBREAKWAITTIME" : ("oplock break wait time", SambaParmString, P_GLOBAL, "0"), + "TIMEOFFSET" : ("time offset", SambaParmString, P_GLOBAL, "0"), + "LDAPDELETEDN" : ("ldap delete dn", SambaParmBool, P_GLOBAL, "No"), + "AFSSHARE" : ("afs share", SambaParmBool, P_LOCAL, "No"), + "ROOT" : ("root directory", SambaParmString, P_GLOBAL, ""), + "NAMERESOLVEORDER" : ("name resolve order", SambaParmString, P_GLOBAL, "lmhosts wins host bcast"), +} +##### end of smbparm.y ########################################## +################################################################# diff --git a/examples/svr4-startup/README b/examples/svr4-startup/README deleted file mode 100644 index 8ed9f74477..0000000000 --- a/examples/svr4-startup/README +++ /dev/null @@ -1,24 +0,0 @@ -Hi and thanks for this great software. - -Solaris (and other sysv) machines have a standardized way of -starting and shutting down services (you may well know that already). - -Here's a piece of code one could place under /etc/init.d -and create appropriate link from, say - - /etc/rc2.d/S99samba.server - -to make smbd start and stop automatically with system bootups and -shutdowns. Each one should edit the lines containing the -daemon calls to agree with his/her installation (the code below -works with the defaults) and workgroup setup (we use the -G and -n -options). - - -I hope this will be of use --- at least it is for me. - -Yours, - -Timo Knuutila -knuutila@cs.utu.fi - diff --git a/examples/svr4-startup/samba.server b/examples/svr4-startup/samba.server deleted file mode 100755 index 0a47fdb10c..0000000000 --- a/examples/svr4-startup/samba.server +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/sh -#ident "@(#)samba.server 1.0 96/06/19 TK" /* SVr4.0 1.1.13.1*/ -# -# Please send info on modifications to knuutila@cs.utu.fi -# -# This file should have uid root, gid sys and chmod 744 -# -if [ ! -d /usr/bin ] -then # /usr not mounted - exit -fi - -killproc() { # kill the named process(es) - pid=`/usr/bin/ps -e | - /usr/bin/grep -w $1 | - /usr/bin/sed -e 's/^ *//' -e 's/ .*//'` - [ "$pid" != "" ] && kill $pid -} - -# Start/stop processes required for samba server - -case "$1" in - -'start') -# -# Edit these lines to suit your installation (paths, workgroup, host) -# - /opt/samba/bin/smbd -D -s/opt/samba/smb.conf - /opt/samba/bin/nmbd -D -l/opt/samba/log -s/opt/samba/smb.conf - ;; -'stop') - killproc nmbd - killproc smbd - ;; -*) - echo "Usage: /etc/init.d/samba.server { start | stop }" - ;; -esac -- cgit