diff options
author | vorlon <vorlon@alioth.debian.org> | 2008-07-20 08:39:10 +0000 |
---|---|---|
committer | vorlon <vorlon@alioth.debian.org> | 2008-07-20 08:39:10 +0000 |
commit | a76d046b2f8155ada2f347f03ef400d760a9a238 (patch) | |
tree | ec6fd098f7e2460565fa5935287aa24d37f915c7 /examples | |
parent | 3e5b49a894ab672fdb6a04f3ba21ef0695d06875 (diff) | |
download | samba-a76d046b2f8155ada2f347f03ef400d760a9a238.tar.gz |
merge samba 3.2 experimental branch to unstable
git-svn-id: svn://svn.debian.org/svn/pkg-samba/trunk/samba@2053 fc4039ab-9d04-0410-8cac-899223bdd6b0
Diffstat (limited to 'examples')
122 files changed, 2478 insertions, 6274 deletions
diff --git a/examples/LDAP/README b/examples/LDAP/README index 7e4b86d253..f6ce3a986e 100644 --- a/examples/LDAP/README +++ b/examples/LDAP/README @@ -17,22 +17,22 @@ and add an include for it in the /etc/openldap/slapd.conf file. Note that samba.schema relies upon the uid and uidNumber attributes from the RFC2307 schema (i.e. nis.schema) -If you choose to import /etc/passwd, nis, or nisplus tables -into ldap, you can use migration tools provided by PADL Software -which are located at +If you choose to import /etc/passwd, nis, or nisplus tables +into ldap, you can use migration tools provided by PADL Software +which are located at http://www.padl.com/tools.html It is not a requirement that a user's /etc/passwd account is stored in LDAP for the samba.schema file to work (although -the whole point of storing smbpasswd in LDAP is to have a +the whole point of storing smbpasswd in LDAP is to have a single location for user accounts, right?) The padl tools will leave you with LDIF files which you can import into OpenLDAP. Before you can import them, you need to include nis.schema and cosine.schema in your slapd.conf file. -You must restart the LDAP server for these new included schema files +You must restart the LDAP server for these new included schema files to become active. SunOne/Netscape DS @@ -48,15 +48,25 @@ Novell eDirectory The schema file has not been updated for the sambaSamAccount objectclass. +Fedora Directory Server / +RedHat Directory Server / +Netscape Directory Server +------------------------- + +An *updated* schema file has been provided, plus a very useful script from +Mike Jackson and Alyseo is available. +ol-schema-migrate.pl can be used to migrate OpenLDAP schema files to FDS +schema ldif files, it can also be used to validate the schema files to +make sure no duplicate OIDs or malformed entries are found. smbldap-tools/ -------------- -The smbldap-tools have been removed from the samba svn -tree. The latest version will continue to be included +The smbldap-tools have been removed from the samba svn +tree. The latest version will continue to be included in Samba releases. -The smbldap-tools package can be downloaded individually from +The smbldap-tools package can be downloaded individually from https://gna.org/projects/smbldap-tools/ !== diff --git a/examples/LDAP/ol-schema-migrate.pl b/examples/LDAP/ol-schema-migrate.pl new file mode 100755 index 0000000000..12392cb4cd --- /dev/null +++ b/examples/LDAP/ol-schema-migrate.pl @@ -0,0 +1,384 @@ +#!/usr/bin/perl -w +# +# Convert OpenLDAP schema files into Fedora DS format with RFC2252 compliant printing +# +# First Release : Mike Jackson <mj@sci.fi> 14 June 2005 +# http://www.netauth.com/~jacksonm/ldap/ol-schema-migrate.pl +# Professional LDAP consulting for large and small projects +# +# - 6 Dec 2005 +# - objectclass element ordering +# +# Second Release : Alyseo <info@alyseo.com> 05 Februrary 2006 +# Francois Billard <francois@alyseo.com> +# Yacine Kheddache <yacine@alyseo.com> +# http://www.alyseo.com/ +# +# - 05 Februrary 2006 +# - parsing improvement to accept non-RFC compliant schemas (like ISPMAN) +# - adding RFC element : Usage, No-user-modification, collective keywords +# - 08 Februrary 2006 +# - adding help & usage +# - now this script can also beautify your schemas: "-b" +# - count attributes and objects class: "-c" +# - display items that can not be converted (empty OID...): "-d" +# - 15 February 2006 +# - adding workaround for Fedora DS bug 181465: +# https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=181465 +# - adding duplicated OID check: "-d" +# Useful to manually correct nasty schemas like: +# https://sourceforge.net/tracker/?func=detail&atid=108390&aid=1429276&group_id=8390 +# - 13 September 2007 +# Based on Samba Team GPL Compliance Officer request, license has been updated from +# GPL to GPLv3+ +# +# - Fedora DS bug you need to correct by hand : +# https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=179956 +# +# GPLv3+ license +# + +my $optionCount = 0; +my $optionPrint = 0; +my $optionBadEntries = 0; +my $optionHelp = 0; +my $filename = "" ; + +foreach (@ARGV) { + $optionHelp = 1 if ( /^-h$/); + $optionCount = 1 if ( /^-c$/); + $optionPrint = 1 if ( /^-b$/); + $optionBadEntries = 1 if ( /^-d$/); + $filename = $_ if ( ! /^-b$/ && ! /^-c$/ && ! /^-d$/); +} + +die "Usage : ol-schema-migrate-v2.pl [ -c ] [ -b ] [ -d ] schema\n" . + " -c\tcount attribute and object class\n" . + " -b\tconvert and beautify your schema\n" . + " -d\tdisplay unrecognized elements, find empty and duplicated OID\n" . + " -h\tthis help\n" if ($filename eq "" || ($optionHelp || (!$optionCount && !$optionPrint && !$optionBadEntries))); + +if($optionCount) { + print "Schema verification counters:\n"; + my $ldapdata = &getSourceFile($filename); + print "".(defined($ldapdata->{attributes}) ? @{$ldapdata->{attributes}} : 0) . " attributes\n"; + print "".(defined($ldapdata->{objectclass}) ? @{$ldapdata->{objectclass}} : 0) . " object classes\n\n" +} + +if($optionPrint) { + my $ldapdata = &getSourceFile($filename); + &printit($ldapdata); +} + +if($optionBadEntries) { + print "Display unrecognized entries:\n"; + my $ldapdata = &getSourceFile($filename); + my $errorsAttr = 0; + my $errorsObjc = 0; + my $errorsDup = 0; + my $emptyOid = 0; + my %dup; + + foreach (@{$ldapdata->{attributes}}) { + my $attr = $_; + + push @{$dup{$attr->{OID}}{attr}}, {NAME => $attr->{NAME}, LINENUMBER => $attr->{LINENUMBER}}; + + $attr->{DATA} =~ s/\n/ /g; + $attr->{DATA} =~ s/\r//g; + $attr->{DATA} =~ s/attribute[t|T]ypes?:?\s*\(//; + $attr->{DATA} =~ s/\Q$attr->{OID}// if(defined $attr->{OID}); + $attr->{DATA} =~ s/NAME\s*\Q$attr->{NAME}// if(defined $attr->{NAME}); + $attr->{DATA} =~ s/DESC\s*'\Q$attr->{DESC}'// if(defined $attr->{DESC}); + $attr->{DATA} =~ s/$attr->{OBSOLETE}// if(defined $attr->{OBSOLETE}); + $attr->{DATA} =~ s/SUP\s*\Q$attr->{SUP}// if(defined $attr->{SUP}); + $attr->{DATA} =~ s/EQUALITY\s*\Q$attr->{EQUALITY}// if(defined $attr->{EQUALITY}); + $attr->{DATA} =~ s/ORDERING\s*\Q$attr->{ORDERING}// if(defined $attr->{ORDERING}); + $attr->{DATA} =~ s/SUBSTR\s*\Q$attr->{SUBSTR}// if(defined $attr->{SUBSTR}); + $attr->{DATA} =~ s/SYNTAX\s*\Q$attr->{SYNTAX}// if(defined $attr->{SYNTAX}); + $attr->{DATA} =~ s/SINGLE-VALUE// if(defined $attr->{SINGLEVALUE}); + $attr->{DATA} =~ s/NO-USER-MODIFICATION// if(defined $attr->{NOUSERMOD}); + $attr->{DATA} =~ s/COLLECTIVE// if(defined $attr->{COLLECTIVE}); + $attr->{DATA} =~ s/USAGE\s*\Q$attr->{USAGE}// if(defined $attr->{USAGE}); + $attr->{DATA} =~ s/\)\s$//; + $attr->{DATA} =~ s/^\s+(\S)/\n$1/ ; + $attr->{DATA} =~ s/(\S)\s+$/$1\n/; + do { + $errorsAttr ++; + do { $emptyOid ++; + print "Warning : no OID for attributes element at line $attr->{LINENUMBER} \n"; + } if( !defined($attr->{OID})); + print "### Unknow element embedded in ATTRIBUTE at line $attr->{LINENUMBER} :\n$attr->{DATA}\n" + } if($attr->{DATA} =~ /\w/); + } + + foreach (@{$ldapdata->{objectclass}}) { + my $objc = $_; + push @{$dup{$objc->{OID}}{objc}} , {NAME => $objc->{NAME}, LINENUMBER => $objc->{LINENUMBER}}; + $objc->{DATA} =~ s/\n/ /g; + $objc->{DATA} =~ s/\r//g; + $objc->{DATA} =~ s/^object[c|C]lasse?s?:?\s*\(?//; + $objc->{DATA} =~ s/\Q$objc->{OID}// if(defined $objc->{OID}); + $objc->{DATA} =~ s/NAME\s*\Q$objc->{NAME}\E// if(defined $objc->{NAME}); + $objc->{DATA} =~ s/DESC\s*'\Q$objc->{DESC}\E'// if(defined $objc->{DESC}); + $objc->{DATA} =~ s/OBSOLETE// if(defined $objc->{OBSOLETE}); + $objc->{DATA} =~ s/SUP\s*\Q$objc->{SUP}// if(defined $objc->{SUP}); + $objc->{DATA} =~ s/\Q$objc->{TYPE}// if(defined $objc->{TYPE}); + $objc->{DATA} =~ s/MUST\s*\Q$objc->{MUST}\E\s*// if(defined $objc->{MUST}); + $objc->{DATA} =~ s/MUST\s*\(?\s*\Q$objc->{MUST}\E\s*\)?// if(defined $objc->{MUST}); + $objc->{DATA} =~ s/MAY\s*\Q$objc->{MAY}\E// if(defined $objc->{MAY}); + $objc->{DATA} =~ s/\)\s$//; + $objc->{DATA} =~ s/^\s+(\S)/\n$1/ ; + $objc->{DATA} =~ s/(\S)\s+$/$1\n/; + + do { + print "#" x 80 ."\n"; + $errorsObjc ++; + do { $emptyOid++ ; + print "Warning : no OID for object class element at line $objc->{LINENUMBER} \n"; + } if( $objc->{OID} eq ""); + print "### Unknow element embedded in OBJECT CLASS at line $objc->{LINENUMBER} :\n$objc->{DATA}\n" + } if($objc->{DATA} =~ /\w/); + } + + my $nbDup = 0; + foreach (keys %dup) { + my $sumOid = 0; + $sumOid += @{$dup{$_}{attr}} if(defined (@{$dup{$_}{attr}})); + $sumOid += @{$dup{$_}{objc}} if(defined (@{$dup{$_}{objc}})); + if( $sumOid > 1 && $_ ne "") { + $nbDup ++; + print "#" x 80 ."\n"; + print "Duplicate OID founds : $_\n"; + foreach (@{$dup{$_}{attr}}) { + + print "Attribute : $_->{NAME} (line : $_->{LINENUMBER})\n"; + } + foreach (@{$dup{$_}{objc}}) { + print "Object class : $_->{NAME} (line : $_->{LINENUMBER})\n"; + } + + } + } + + print "\n$errorsAttr errors detected in ATTRIBUTES list\n"; + print "$errorsObjc errors detected in OBJECT CLASS list\n"; + print "$nbDup duplicate OID founds\n"; + print "$emptyOid empty OID fields founds\n\n"; + +} + + +sub printit { + my $ldapdata = shift; + &printSeparator; + print "dn: cn=schema\n"; + &printSeparator; + + # print elements in RFC2252 order + + foreach (@{$ldapdata->{attributes}}) { + my $attr = $_; + print "attributeTypes: (\n"; + print " $attr->{OID}\n"; + print " NAME $attr->{NAME}\n"; + print " DESC '$attr->{DESC}'\n" if(defined $attr->{DESC}); + print " OBSOLETE\n" if(defined $attr->{OBSOLETE}); + print " SUP $attr->{SUP}\n" if(defined $attr->{SUP}); + print " EQUALITY $attr->{EQUALITY}\n" if(defined $attr->{EQUALITY}); + print " ORDERING $attr->{ORDERING}\n" if(defined $attr->{ORDERING}); + print " SUBSTR $attr->{SUBSTR}\n" if(defined $attr->{SUBSTR}); + print " SYNTAX $attr->{SYNTAX}\n" if(defined $attr->{SYNTAX}); + print " SINGLE-VALUE\n" if(defined $attr->{SINGLEVALUE}); + print " NO-USER-MODIFICATION\n" if(defined $attr->{NOUSERMOD}); + print " COLLECTIVE\n" if(defined $attr->{COLLECTIVE}); + print " USAGE $attr->{USAGE}\n" if(defined $attr->{USAGE}); + print " )\n"; + &printSeparator; + } + + foreach (@{$ldapdata->{objectclass}}) { + my $objc = $_; + # next 3 lines : Fedora DS space sensitive bug workaround + $objc->{SUP} =~ s/^\(\s*(.*?)\s*\)$/\( $1 \)/ if (defined $objc->{SUP}); + $objc->{MUST} =~ s/^\(\s*(.*?)\s*\)$/\( $1 \)/ if (defined $objc->{MUST}); + $objc->{MAY} =~ s/^\(\s*(.*?)\s*\)$/\( $1 \)/ if (defined $objc->{MAY}); + + print "objectClasses: (\n"; + print " $objc->{OID}\n"; + print " NAME $objc->{NAME}\n"; + print " DESC '$objc->{DESC}'\n" if(defined $objc->{DESC}); + print " OBSOLETE\n" if(defined $objc->{OBSOLETE}); + print " SUP $objc->{SUP}\n" if(defined $objc->{SUP}); + print " $objc->{TYPE}\n" if(defined $objc->{TYPE}); + print " MUST $objc->{MUST}\n" if(defined $objc->{MUST}); + print " MAY $objc->{MAY}\n" if(defined $objc->{MAY}); + print " )\n"; + &printSeparator; + } +} + +sub printSeparator { + print "#\n"; + print "#" x 80 . "\n"; + print "#\n"; +} + +sub getSourceFile { + my @data = &getFile(shift); + my %result; + my $result = \%result; + my @allattrs; + my @allattrsLineNumber; + my @allobjc; + my @allobjcLineNumber; + my $at = 0; + my $oc = 0; + my $at_string; + my $oc_string; + my $idx = 0; + my $beginParenthesis = 0; + my $endParenthesis = 0; + my $lineNumber = 0; + for(@data) { + $lineNumber++; + next if (/^\s*\#/); # skip comments + + if($at) { + s/ +/ /; # remove embedded tabs + s/\t/ /; # remove multiple spaces after the $ sign + + $at_string .= $_; + $beginParenthesis = 0; # Use best matching elements + $endParenthesis = 0; + for(my $i=0;$ i < length($at_string); $i++) { + $beginParenthesis++ if(substr ($at_string,$i,1) eq "("); + $endParenthesis++ if(substr ($at_string,$i,1) eq ")"); + } + if($beginParenthesis == $endParenthesis) { + push @allattrs, $at_string; + $at = 0; + $at_string = ""; + $endParenthesis = 0; + $beginParenthesis = 0; + } + } + + if (/^attribute[t|T]ype/) { + my $line = $_; + push @allattrsLineNumber, $lineNumber; # keep starting line number + for(my $i=0;$ i < length($line); $i++) { + $beginParenthesis++ if(substr ($line, $i, 1) eq "("); + $endParenthesis++ if(substr ($line, $i, 1) eq ")"); + } + if($beginParenthesis == $endParenthesis && $beginParenthesis != 0) { + push @allattrs, $line; + $endParenthesis = 0; + $beginParenthesis = 0; + } else { + $at_string = $line; + $at = 1; + } + } + + ##################################### + + if($oc) { + s/ +/ /; + s/\t/ /; + + $oc_string .= $_; + $endParenthesis = 0; # best methode to accept an elements : + $beginParenthesis = 0; # left parenthesis sum == right parenthesis sum, so we are sure to + for(my $i=0;$ i < length($oc_string); $i++) { # have an element. + $beginParenthesis++ if(substr ($oc_string, $i, 1) eq "("); + $endParenthesis++ if(substr ($oc_string, $i, 1) eq ")"); + } + if($beginParenthesis == $endParenthesis) { + push @allobjc, $oc_string; + $oc = 0; + $oc_string = ""; + $endParenthesis = 0; + $beginParenthesis = 0; + } + } + + if (/^object[c|C]lass/) { + my $line = $_; + push @allobjcLineNumber, $lineNumber; # keep starting line number + for(my $i=0;$ i < length($line); $i++) { + $beginParenthesis++ if(substr ($line, $i, 1) eq "("); + $endParenthesis++ if(substr ($line, $i, 1) eq ")"); + } + if($beginParenthesis == $endParenthesis && $beginParenthesis != 0) { + push @allobjc, $line; + $endParenthesis = 0; + $beginParenthesis = 0; + } else { + $oc_string = $line; + $oc = 1; + } + } + } + + # Parsing attribute elements + + for(@allattrs) { + s/\n/ /g; + s/\r//g; + s/ +/ /g; + s/\t/ /g; + $result->{attributes}->[$idx]->{DATA} = $_ if($optionBadEntries); # keep original data + $result->{attributes}->[$idx]->{LINENUMBER} = $allattrsLineNumber[$idx]; + $result->{attributes}->[$idx]->{OID} = $1 if (m/^attribute[t|T]ypes?:?\s*\(?\s*([\.\d]*?)\s+/); + $result->{attributes}->[$idx]->{NAME} = $1 if (m/NAME\s+('.*?')\s*/ || m/NAME\s+(\(.*?\))/); + $result->{attributes}->[$idx]->{DESC} = $1 if (m/DESC\s+'(.*?)'\s*/); + $result->{attributes}->[$idx]->{OBSOLETE} = "OBSOLETE" if (m/OBSOLETE/); + $result->{attributes}->[$idx]->{SUP} = $1 if (m/SUP\s+(.*?)\s/); + $result->{attributes}->[$idx]->{EQUALITY} = $1 if (m/EQUALITY\s+(.*?)\s/); + $result->{attributes}->[$idx]->{ORDERING} = $1 if (m/ORDERING\s+(.*?)\s/); + $result->{attributes}->[$idx]->{SUBSTR} = $1 if (m/SUBSTR\s+(.*?)\s/); + $result->{attributes}->[$idx]->{SYNTAX} = $1 if (m/SYNTAX\s+(.*?)(\s|\))/); + $result->{attributes}->[$idx]->{SINGLEVALUE} = "SINGLE-VALUE" if (m/SINGLE-VALUE/); + $result->{attributes}->[$idx]->{COLLECTIVE} = "COLLECTIVE" if (m/COLLECTIVE/); + $result->{attributes}->[$idx]->{USAGE} = $1 if (m/USAGE\s+(.*?)\s/); + $result->{attributes}->[$idx]->{NOUSERMOD} = "NO-USER-MODIFICATION" if (m/NO-USER-MODIFICATION/); + $idx ++; + } + + $idx = 0; + + # Parsing object class elements + + for(@allobjc) { + s/\n/ /g; + s/\r//g; + s/ +/ /g; + s/\t/ /g; + $result->{objectclass}->[$idx]->{DATA} = $_ if($optionBadEntries); # keep original data + $result->{objectclass}->[$idx]->{LINENUMBER} = $allobjcLineNumber[$idx]; + $result->{objectclass}->[$idx]->{OID} = $1 if (m/^object[c|C]lasse?s?:?\s*\(?\s*([\.\d]*?)\s+/); + $result->{objectclass}->[$idx]->{NAME} = $1 if (m/NAME\s+('.*?')\s*/ || m/NAME\s+(\(.*?\))/); + $result->{objectclass}->[$idx]->{DESC} = $1 if (m/DESC\s+'(.*?)'\s*/); + $result->{objectclass}->[$idx]->{OBSOLETE} = "OBSOLETE" if (m/OBSOLETE/); + $result->{objectclass}->[$idx]->{SUP} = $1 if (m/SUP\s+([^()]+?)\s/ || m/SUP\s+(\(.+?\))\s/); + $result->{objectclass}->[$idx]->{TYPE} = $1 if (m/((?:STRUCTURAL)|(?:AUXILIARY)|(?:ABSTRACT))/); + $result->{objectclass}->[$idx]->{MUST} = $1 if (m/MUST\s+(\w+)\)?/ || m/MUST\s+(\(.*?\))(\s|\))/s); + $result->{objectclass}->[$idx]->{MAY} = $1 if (m/MAY\s+(\w+)\)?/ || m/MAY\s+(\(.*?\))(\s|\))/s); + + $idx++; + } + + return $result; +} + +sub getFile { + my @data; + my $file = shift; + die "File not found : $file\n" if(! -e $file); + open FH, $file; + @data = <FH>; + close FH; + @data; +} + diff --git a/examples/LDAP/samba-schema-FDS.ldif b/examples/LDAP/samba-schema-FDS.ldif new file mode 100644 index 0000000000..e88559fc8a --- /dev/null +++ b/examples/LDAP/samba-schema-FDS.ldif @@ -0,0 +1,156 @@ +## schema file for Fedora/RedHat Directory Server +## +## NOTE: this file can be copied as 60samba.ldif into your instance schema +## directory: +## cp samba-schema-FDS.ldif /etc/dirsrv/slapd-<instance-name>/schema/60schema.ldif +## +## Schema for storing Samba user accounts and group maps in LDAP +## OIDs are owned by the Samba Team +## +## Prerequisite schemas - uid (cosine.schema) +## - displayName (inetorgperson.schema) +## - gidNumber (nis.schema) +## +## 1.3.6.1.4.1.7165.2.1.x - attributeTypess +## 1.3.6.1.4.1.7165.2.2.x - objectClasseses +## +## Printer support +## 1.3.6.1.4.1.7165.2.3.1.x - attributeTypess +## 1.3.6.1.4.1.7165.2.3.2.x - objectClasseses +## +## Samba4 +## 1.3.6.1.4.1.7165.4.1.x - attributeTypess +## 1.3.6.1.4.1.7165.4.2.x - objectClasseses +## 1.3.6.1.4.1.7165.4.3.x - LDB/LDAP Controls +## 1.3.6.1.4.1.7165.4.4.x - LDB/LDAP Extended Operations +## 1.3.6.1.4.1.7165.4.255.x - mapped OIDs due to conflicts between AD and standards-track +## +dn: cn=schema +## +####################################################################### +## Attributes used by Samba 3.0 schema ## +####################################################################### +## +## Password hashes## +attributeTypes: ( 1.3.6.1.4.1.7165.2.1.24 NAME 'sambaLMPassword' DESC 'LanManager Password' EQUALITY caseIgnoreIA5Match SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{32} SINGLE-VALUE ) +attributeTypes: ( 1.3.6.1.4.1.7165.2.1.25 NAME 'sambaNTPassword' DESC 'MD4 hash of the unicode password' EQUALITY caseIgnoreIA5Match SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{32} SINGLE-VALUE ) +## +## Account flags in string format ([UWDX ]) +## +attributeTypes: ( 1.3.6.1.4.1.7165.2.1.26 NAME 'sambaAcctFlags' DESC 'Account Flags' EQUALITY caseIgnoreIA5Match SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{16} SINGLE-VALUE ) +## +## Password timestamps & policies +## +attributeTypes: ( 1.3.6.1.4.1.7165.2.1.27 NAME 'sambaPwdLastSet' DESC 'Timestamp of the last password update' EQUALITY integerMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE ) +attributeTypes: ( 1.3.6.1.4.1.7165.2.1.28 NAME 'sambaPwdCanChange' DESC 'Timestamp of when the user is allowed to update the password' EQUALITY integerMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE ) +attributeTypes: ( 1.3.6.1.4.1.7165.2.1.29 NAME 'sambaPwdMustChange' DESC 'Timestamp of when the password will expire' EQUALITY integerMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE ) +attributeTypes: ( 1.3.6.1.4.1.7165.2.1.30 NAME 'sambaLogonTime' DESC 'Timestamp of last logon' EQUALITY integerMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE ) +attributeTypes: ( 1.3.6.1.4.1.7165.2.1.31 NAME 'sambaLogoffTime' DESC 'Timestamp of last logoff' EQUALITY integerMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE ) +attributeTypes: ( 1.3.6.1.4.1.7165.2.1.32 NAME 'sambaKickoffTime' DESC 'Timestamp of when the user will be logged off automatically' EQUALITY integerMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE ) +attributeTypes: ( 1.3.6.1.4.1.7165.2.1.48 NAME 'sambaBadPasswordCount' DESC 'Bad password attempt count' EQUALITY integerMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE ) +attributeTypes: ( 1.3.6.1.4.1.7165.2.1.49 NAME 'sambaBadPasswordTime' DESC 'Time of the last bad password attempt' EQUALITY integerMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE ) +attributeTypes: ( 1.3.6.1.4.1.7165.2.1.55 NAME 'sambaLogonHours' DESC 'Logon Hours' EQUALITY caseIgnoreIA5Match SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{42} SINGLE-VALUE ) +## +## string settings +## +attributeTypes: ( 1.3.6.1.4.1.7165.2.1.33 NAME 'sambaHomeDrive' DESC 'Driver letter of home directory mapping' EQUALITY caseIgnoreIA5Match SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{4} SINGLE-VALUE ) +attributeTypes: ( 1.3.6.1.4.1.7165.2.1.34 NAME 'sambaLogonScript' DESC 'Logon script path' EQUALITY caseIgnoreMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{255} SINGLE-VALUE ) +attributeTypes: ( 1.3.6.1.4.1.7165.2.1.35 NAME 'sambaProfilePath' DESC 'Roaming profile path' EQUALITY caseIgnoreMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{255} SINGLE-VALUE ) +attributeTypes: ( 1.3.6.1.4.1.7165.2.1.36 NAME 'sambaUserWorkstations' DESC 'List of user workstations the user is allowed to logon to' EQUALITY caseIgnoreMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{255} SINGLE-VALUE ) +attributeTypes: ( 1.3.6.1.4.1.7165.2.1.37 NAME 'sambaHomePath' DESC 'Home directory UNC path' EQUALITY caseIgnoreMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{128} ) +attributeTypes: ( 1.3.6.1.4.1.7165.2.1.38 NAME 'sambaDomainName' DESC 'Windows NT domain to which the user belongs' EQUALITY caseIgnoreMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{128} ) +attributeTypes: ( 1.3.6.1.4.1.7165.2.1.47 NAME 'sambaMungedDial' DESC 'Base64 encoded user parameter string' EQUALITY caseExactMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{1050} ) +attributeTypes: ( 1.3.6.1.4.1.7165.2.1.54 NAME 'sambaPasswordHistory' DESC 'Concatenated MD5 hashes of the salted NT passwords used on this account' EQUALITY caseIgnoreIA5Match SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{32} ) +## +## SID, of any type +## +attributeTypes: ( 1.3.6.1.4.1.7165.2.1.20 NAME 'sambaSID' DESC 'Security ID' EQUALITY caseIgnoreIA5Match SUBSTR caseExactIA5SubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{64} SINGLE-VALUE ) +## +## Primary group SID, compatible with ntSid +## +attributeTypes: ( 1.3.6.1.4.1.7165.2.1.23 NAME 'sambaPrimaryGroupSID' DESC 'Primary Group Security ID' EQUALITY caseIgnoreIA5Match SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{64} SINGLE-VALUE ) +attributeTypes: ( 1.3.6.1.4.1.7165.2.1.51 NAME 'sambaSIDList' DESC 'Security ID List' EQUALITY caseIgnoreIA5Match SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{64} ) +## +## group mapping attributes +## +attributeTypes: ( 1.3.6.1.4.1.7165.2.1.19 NAME 'sambaGroupType' DESC 'NT Group Type' EQUALITY integerMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE ) +## +## Store info on the domain +## +attributeTypes: ( 1.3.6.1.4.1.7165.2.1.21 NAME 'sambaNextUserRid' DESC 'Next NT rid to give our for users' EQUALITY integerMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE ) +attributeTypes: ( 1.3.6.1.4.1.7165.2.1.22 NAME 'sambaNextGroupRid' DESC 'Next NT rid to give out for groups' EQUALITY integerMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE ) +attributeTypes: ( 1.3.6.1.4.1.7165.2.1.39 NAME 'sambaNextRid' DESC 'Next NT rid to give out for anything' EQUALITY integerMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE ) +attributeTypes: ( 1.3.6.1.4.1.7165.2.1.40 NAME 'sambaAlgorithmicRidBase' DESC 'Base at which the samba RID generation algorithm should operate' EQUALITY integerMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE ) +attributeTypes: ( 1.3.6.1.4.1.7165.2.1.41 NAME 'sambaShareName' DESC 'Share Name' EQUALITY caseIgnoreMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE ) +attributeTypes: ( 1.3.6.1.4.1.7165.2.1.42 NAME 'sambaOptionName' DESC 'Option Name' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{256} ) +attributeTypes: ( 1.3.6.1.4.1.7165.2.1.43 NAME 'sambaBoolOption' DESC 'A boolean option' EQUALITY booleanMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 SINGLE-VALUE ) +attributeTypes: ( 1.3.6.1.4.1.7165.2.1.44 NAME 'sambaIntegerOption' DESC 'An integer option' EQUALITY integerMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE ) +attributeTypes: ( 1.3.6.1.4.1.7165.2.1.45 NAME 'sambaStringOption' DESC 'A string option' EQUALITY caseExactIA5Match SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE ) +attributeTypes: ( 1.3.6.1.4.1.7165.2.1.46 NAME 'sambaStringListOption' DESC 'A string list option' EQUALITY caseIgnoreMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 ) +##attributeTypes: ( 1.3.6.1.4.1.7165.2.1.50 NAME 'sambaPrivName' +## SUP name ) +## +##attributeTypes: ( 1.3.6.1.4.1.7165.2.1.52 NAME 'sambaPrivilegeList' +## DESC 'Privileges List' +## EQUALITY caseIgnoreIA5Match +## SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{64} ) +attributeTypes: ( 1.3.6.1.4.1.7165.2.1.53 NAME 'sambaTrustFlags' DESC 'Trust Password Flags' EQUALITY caseIgnoreIA5Match SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 ) +# "min password length" +attributeTypes: ( 1.3.6.1.4.1.7165.2.1.58 NAME 'sambaMinPwdLength' DESC 'Minimal password length (default: 5)' EQUALITY integerMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE ) +# "password history" +attributeTypes: ( 1.3.6.1.4.1.7165.2.1.59 NAME 'sambaPwdHistoryLength' DESC 'Length of Password History Entries (default: 0 => off)' EQUALITY integerMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE ) +# "user must logon to change password" +attributeTypes: ( 1.3.6.1.4.1.7165.2.1.60 NAME 'sambaLogonToChgPwd' DESC 'Force Users to logon for password change (default: 0 => off, 2 => on)' EQUALITY integerMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE ) +# "maximum password age" +attributeTypes: ( 1.3.6.1.4.1.7165.2.1.61 NAME 'sambaMaxPwdAge' DESC 'Maximum password age, in seconds (default: -1 => never expire passwords)' EQUALITY integerMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE ) +# "minimum password age" +attributeTypes: ( 1.3.6.1.4.1.7165.2.1.62 NAME 'sambaMinPwdAge' DESC 'Minimum password age, in seconds (default: 0 => allow immediate password change)' EQUALITY integerMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE ) +# "lockout duration" +attributeTypes: ( 1.3.6.1.4.1.7165.2.1.63 NAME 'sambaLockoutDuration' DESC 'Lockout duration in minutes (default: 30, -1 => forever)' EQUALITY integerMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE ) +# "reset count minutes" +attributeTypes: ( 1.3.6.1.4.1.7165.2.1.64 NAME 'sambaLockoutObservationWindow' DESC 'Reset time after lockout in minutes (default: 30)' EQUALITY integerMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE ) +# "bad lockout attempt" +attributeTypes: ( 1.3.6.1.4.1.7165.2.1.65 NAME 'sambaLockoutThreshold' DESC 'Lockout users after bad logon attempts (default: 0 => off)' EQUALITY integerMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE ) +# "disconnect time" +attributeTypes: ( 1.3.6.1.4.1.7165.2.1.66 NAME 'sambaForceLogoff' DESC 'Disconnect Users outside logon hours (default: -1 => off, 0 => on)' EQUALITY integerMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE ) +# "refuse machine password change" +attributeTypes: ( 1.3.6.1.4.1.7165.2.1.67 NAME 'sambaRefuseMachinePwdChange' DESC 'Allow Machine Password changes (default: 0 => off)' EQUALITY integerMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE ) +## +####################################################################### +## objectClasses: used by Samba 3.0 schema ## +####################################################################### +## +## The X.500 data model (and therefore LDAPv3) says that each entry can +## only have one structural objectClasses. OpenLDAP 2.0 does not enforce +## this currently but will in v2.1 +## +## added new objectClasses: (and OID) for 3.0 to help us deal with backwards +## compatibility with 2.2 installations (e.g. ldapsam_compat) --jerry +## +objectClasses: ( 1.3.6.1.4.1.7165.2.2.6 NAME 'sambaSamAccount' SUP top AUXILIARY DESC 'Samba 3.0 Auxilary SAM Account' MUST ( uid $ sambaSID ) MAY ( cn $ sambaLMPassword $ sambaNTPassword $ sambaPwdLastSet $ sambaLogonTime $ sambaLogoffTime $ sambaKickoffTime $ sambaPwdCanChange $ sambaPwdMustChange $ sambaAcctFlags $ displayName $ sambaHomePath $ sambaHomeDrive $ sambaLogonScript $ sambaProfilePath $ description $ sambaUserWorkstations $ sambaPrimaryGroupSID $ sambaDomainName $ sambaMungedDial $ sambaBadPasswordCount $ sambaBadPasswordTime $ sambaPasswordHistory $ sambaLogonHours)) +## +## Group mapping info +## +objectClasses: ( 1.3.6.1.4.1.7165.2.2.4 NAME 'sambaGroupMapping' SUP top AUXILIARY DESC 'Samba Group Mapping' MUST ( gidNumber $ sambaSID $ sambaGroupType ) MAY ( displayName $ description $ sambaSIDList )) +## +## Trust password for trust relationships (any kind) +## +objectClasses: ( 1.3.6.1.4.1.7165.2.2.14 NAME 'sambaTrustPassword' SUP top STRUCTURAL DESC 'Samba Trust Password' MUST ( sambaDomainName $ sambaNTPassword $ sambaTrustFlags ) MAY ( sambaSID $ sambaPwdLastSet )) +## +## Whole-of-domain info +## +objectClasses: ( 1.3.6.1.4.1.7165.2.2.5 NAME 'sambaDomain' SUP top STRUCTURAL DESC 'Samba Domain Information' MUST ( sambaDomainName $ sambaSID ) MAY ( sambaNextRid $ sambaNextGroupRid $ sambaNextUserRid $ sambaAlgorithmicRidBase $ sambaMinPwdLength $ sambaPwdHistoryLength $ sambaLogonToChgPwd $ sambaMaxPwdAge $ sambaMinPwdAge $ sambaLockoutDuration $ sambaLockoutObservationWindow $ sambaLockoutThreshold $ sambaForceLogoff $ sambaRefuseMachinePwdChange )) +## +## used for idmap_ldap module +## +objectClasses: ( 1.3.6.1.4.1.7165.2.2.7 NAME 'sambaUnixIdPool' SUP top AUXILIARY DESC 'Pool for allocating UNIX uids/gids' MUST ( uidNumber $ gidNumber ) ) +objectClasses: ( 1.3.6.1.4.1.7165.2.2.8 NAME 'sambaIdmapEntry' SUP top AUXILIARY DESC 'Mapping from a SID to an ID' MUST ( sambaSID ) MAY ( uidNumber $ gidNumber ) ) +objectClasses: ( 1.3.6.1.4.1.7165.2.2.9 NAME 'sambaSidEntry' SUP top STRUCTURAL DESC 'Structural Class for a SID' MUST ( sambaSID ) ) +objectClasses: ( 1.3.6.1.4.1.7165.2.2.10 NAME 'sambaConfig' SUP top AUXILIARY DESC 'Samba Configuration Section' MAY ( description ) ) +objectClasses: ( 1.3.6.1.4.1.7165.2.2.11 NAME 'sambaShare' SUP top STRUCTURAL DESC 'Samba Share Section' MUST ( sambaShareName ) MAY ( description ) ) +objectClasses: ( 1.3.6.1.4.1.7165.2.2.12 NAME 'sambaConfigOption' SUP top STRUCTURAL DESC 'Samba Configuration Option' MUST ( sambaOptionName ) MAY ( sambaBoolOption $ sambaIntegerOption $ sambaStringOption $ sambaStringListoption $ description ) ) +## retired during privilege rewrite +##objectClasses: ( 1.3.6.1.4.1.7165.2.2.13 NAME 'sambaPrivilege' SUP top AUXILIARY +## DESC 'Samba Privilege' +## MUST ( sambaSID ) +## MAY ( sambaPrivilegeList ) ) diff --git a/examples/LDAP/samba.schema b/examples/LDAP/samba.schema index 549a708862..8f82dddeb3 100644 --- a/examples/LDAP/samba.schema +++ b/examples/LDAP/samba.schema @@ -457,6 +457,17 @@ attributetype ( 1.3.6.1.4.1.7165.2.1.67 NAME 'sambaRefuseMachinePwdChange' EQUALITY integerMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE ) +# +attributetype ( 1.3.6.1.4.1.7165.2.1.68 NAME 'sambaClearTextPassword' + DESC 'Clear text password (used for trusted domain passwords)' + EQUALITY octetStringMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 ) + +# +attributetype ( 1.3.6.1.4.1.7165.2.1.69 NAME 'sambaPreviousClearTextPassword' + DESC 'Previous clear text password (used for trusted domain passwords)' + EQUALITY octetStringMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 ) @@ -501,6 +512,16 @@ objectclass ( 1.3.6.1.4.1.7165.2.2.14 NAME 'sambaTrustPassword' SUP top STRUCTUR MAY ( sambaSID $ sambaPwdLastSet )) ## +## Trust password for trusted domains +## (to be stored beneath the trusting sambaDomain object in the DIT) +## +objectclass ( 1.3.6.1.4.1.7165.2.2.15 NAME 'sambaTrustedDomainPassword' SUP top STRUCTURAL + DESC 'Samba Trusted Domain Password' + MUST ( sambaDomainName $ sambaSID $ + sambaClearTextPassword $ sambaPwdLastSet ) + MAY ( sambaPreviousClearTextPassword )) + +## ## Whole-of-domain info ## objectclass ( 1.3.6.1.4.1.7165.2.2.5 NAME 'sambaDomain' SUP top STRUCTURAL diff --git a/examples/VFS/Makefile.in b/examples/VFS/Makefile.in index 8869a4f20d..4de0efd29e 100644 --- a/examples/VFS/Makefile.in +++ b/examples/VFS/Makefile.in @@ -12,7 +12,7 @@ FLAGS = $(CFLAGS) $(CPPFLAGS) -fPIC \ -I$(SAMBA_SOURCE)/popt \ -I$(SAMBA_SOURCE)/lib/replace \ -I$(SAMBA_SOURCE)/lib/talloc \ - -I$(SAMBA_SOURCE)/tdb/include \ + -I$(SAMBA_SOURCE)/lib/tdb/include \ -I$(SAMBA_SOURCE)/smbwrapper \ -I$(SAMBA_SOURCE)/librpc \ -I$(SAMBA_SOURCE) -I. diff --git a/examples/VFS/config.guess b/examples/VFS/config.guess index d0d57f6945..600580b1aa 100755 --- a/examples/VFS/config.guess +++ b/examples/VFS/config.guess @@ -7,7 +7,7 @@ timestamp='2005-09-19' # This file 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 +# the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but @@ -16,9 +16,7 @@ timestamp='2005-09-19' # General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA -# 02110-1301, USA. +# along with this program; if not, see <http://www.gnu.org/licenses/>. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a diff --git a/examples/VFS/config.sub b/examples/VFS/config.sub index 1c366dfde9..23cd6fd75c 100755 --- a/examples/VFS/config.sub +++ b/examples/VFS/config.sub @@ -11,7 +11,7 @@ timestamp='2005-07-08' # # This file 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 +# the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, @@ -20,9 +20,7 @@ timestamp='2005-07-08' # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA -# 02110-1301, USA. +# along with this program; if not, see <http://www.gnu.org/licenses/>. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a diff --git a/examples/VFS/configure.in b/examples/VFS/configure.in index 1a0ff6bb4c..b8e10d482b 100644 --- a/examples/VFS/configure.in +++ b/examples/VFS/configure.in @@ -5,14 +5,14 @@ dnl We must use autotools 2.53 or above AC_PREREQ(2.53) AC_INIT(Makefile.in) -#dnl Uncomment this if you want to use your own define's too -#AC_CONFIG_HEADER(module_config.h) +AC_CONFIG_HEADER(module_config.h) #dnl To make sure that didn't get #define PACKAGE_* in modules_config.h #echo "" > confdefs.h dnl Checks for programs. AC_PROG_CC AC_PROG_INSTALL +AC_CANONICAL_HOST ################################################# # Directory handling stuff to support both the @@ -313,6 +313,11 @@ if test "$enable_shared" = "yes"; then BLDSHARED="false" LDSHFLAGS="" ;; + *darwin*) + BLDSHARED="true" + LDSHFLAGS="-bundle -flat_namespace -undefined suppress" + SHLIBEXT="dylib" + ;; *) ;; esac @@ -332,7 +337,7 @@ AC_CACHE_CHECK([whether building shared libraries actually works], ac_cv_shlib_works=no # try building a trivial shared library if test "$PICSUFFIX" = "po"; then - $CC $CPPFLAGS $CFLAGS $PICFLAGS -c -o shlib.po ${srcdir-.}/tests/shlib.c && + $CC $CPPFLAGS $CFLAGS $PICFLAGS -c -o shlib.po ${srcdir-.}/../../source/tests/shlib.c && $CC $CPPFLAGS $CFLAGS `eval echo $LDSHFLAGS` -o "shlib.$SHLIBEXT" shlib.po && ac_cv_shlib_works=yes else diff --git a/examples/VFS/shadow_copy_test.c b/examples/VFS/shadow_copy_test.c index 98ac304ee2..1ba46b7176 100644 --- a/examples/VFS/shadow_copy_test.c +++ b/examples/VFS/shadow_copy_test.c @@ -5,7 +5,7 @@ * * 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 + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, @@ -14,8 +14,7 @@ * 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. + * along with this program; if not, see <http://www.gnu.org/licenses/>. */ #include "includes.h" @@ -50,7 +49,7 @@ Directories are always displayed... */ -static int test_get_shadow_copy_data(vfs_handle_struct *handle, files_struct *fsp, SHADOW_COPY_DATA *shadow_copy_data, BOOL labels) +static int test_get_shadow_copy_data(vfs_handle_struct *handle, files_struct *fsp, SHADOW_COPY_DATA *shadow_copy_data, bool labels) { uint32 num = 3; uint32 i; diff --git a/examples/VFS/skel_opaque.c b/examples/VFS/skel_opaque.c index 7103d0c27b..eb49f35c04 100644 --- a/examples/VFS/skel_opaque.c +++ b/examples/VFS/skel_opaque.c @@ -8,7 +8,7 @@ * * 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 + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, @@ -17,8 +17,7 @@ * 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. + * along with this program; if not, see <http://www.gnu.org/licenses/>. */ @@ -54,7 +53,7 @@ static void skel_disconnect(vfs_handle_struct *handle, connection_struct *conn) } static SMB_BIG_UINT skel_disk_free(vfs_handle_struct *handle, const char *path, - BOOL small_query, SMB_BIG_UINT *bsize, + bool small_query, SMB_BIG_UINT *bsize, SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize) { return vfswrap_disk_free(NULL, path, small_query, bsize, @@ -71,7 +70,7 @@ static int skel_set_quota(vfs_handle_struct *handle, enum SMB_QUOTA_TYPE qtype, return vfswrap_set_quota(NULL, qtype, id, dq); } -static int skel_get_shadow_copy_data(vfs_handle_struct *handle, files_struct *fsp, SHADOW_COPY_DATA *shadow_copy_data, BOOL labels) +static int skel_get_shadow_copy_data(vfs_handle_struct *handle, files_struct *fsp, SHADOW_COPY_DATA *shadow_copy_data, bool labels) { return vfswrap_get_shadow_copy_data(NULL, fsp, shadow_copy_data, labels); } @@ -93,7 +92,7 @@ static SMB_STRUCT_DIRENT *skel_readdir(vfs_handle_struct *handle, SMB_STRUCT_DI static void skel_seekdir(vfs_handle_struct *handle, SMB_STRUCT_DIR *dirp, long offset) { - return vfswrap_seekdir(NULL, dirp, offset); + vfswrap_seekdir(NULL, dirp, offset); } static long skel_telldir(vfs_handle_struct *handle, SMB_STRUCT_DIR *dirp) @@ -103,7 +102,7 @@ static long skel_telldir(vfs_handle_struct *handle, SMB_STRUCT_DIR *dirp) static void skel_rewinddir(vfs_handle_struct *handle, SMB_STRUCT_DIR *dirp) { - return vfswrap_rewinddir(NULL, dirp); + vfswrap_rewinddir(NULL, dirp); } static int skel_mkdir(vfs_handle_struct *handle, const char *path, mode_t mode) @@ -126,34 +125,45 @@ static int skel_open(vfs_handle_struct *handle, const char *fname, files_struct return vfswrap_open(NULL, fname, flags, mode); } -static int skel_close(vfs_handle_struct *handle, files_struct *fsp, int fd) +static int skel_close(vfs_handle_struct *handle, files_struct *fsp) { - return vfswrap_close(NULL, fsp, fd); + return vfswrap_close(NULL, fsp); } -static ssize_t skel_read(vfs_handle_struct *handle, files_struct *fsp, int fd, void *data, size_t n) +static ssize_t skel_read(vfs_handle_struct *handle, files_struct *fsp, void *data, size_t n) { - return vfswrap_read(NULL, fsp, fd, data, n); + return vfswrap_read(NULL, fsp, data, n); } -static ssize_t skel_pread(vfs_handle_struct *handle, struct files_struct *fsp, int fd, void *data, size_t n, SMB_OFF_T offset) +static ssize_t skel_pread(vfs_handle_struct *handle, struct files_struct *fsp, void *data, size_t n, SMB_OFF_T offset) { - return vfswrap_pread(NULL, fsp, fd, data, n, offset); + return vfswrap_pread(NULL, fsp, data, n, offset); } -static ssize_t skel_write(vfs_handle_struct *handle, files_struct *fsp, int fd, const void *data, size_t n) +static ssize_t skel_write(vfs_handle_struct *handle, files_struct *fsp, const void *data, size_t n) { - return vfswrap_write(NULL, fsp, fd, data, n); + return vfswrap_write(NULL, fsp, data, n); } -ssize_t skel_pwrite(vfs_handle_struct *handle, struct files_struct *fsp, int fd, const void *data, size_t n, SMB_OFF_T offset) +ssize_t skel_pwrite(vfs_handle_struct *handle, struct files_struct *fsp, const void *data, size_t n, SMB_OFF_T offset) { - return vfswrap_pwrite(NULL, fsp, fd, data, n, offset); + return vfswrap_pwrite(NULL, fsp, data, n, offset); } -static SMB_OFF_T skel_lseek(vfs_handle_struct *handle, files_struct *fsp, int filedes, SMB_OFF_T offset, int whence) +static SMB_OFF_T skel_lseek(vfs_handle_struct *handle, files_struct *fsp, SMB_OFF_T offset, int whence) { - return vfswrap_lseek(NULL, fsp, filedes, offset, whence); + return vfswrap_lseek(NULL, fsp, offset, whence); +} + +static ssize_t skel_sendfile(vfs_handle_struct *handle, int tofd, files_struct *fromfsp, const DATA_BLOB *hdr, + SMB_OFF_T offset, size_t n) +{ + return vfswrap_sendfile(NULL, tofd, fromfsp, hdr, offset, n); +} + +static ssize_t skel_recvfile(vfs_handle_struct *handle, int fromfd, files_struct *tofsp, SMB_OFF_T offset, size_t n) +{ + return vfswrap_recvfile(NULL, fromfd, tofsp, offset, n); } static int skel_rename(vfs_handle_struct *handle, const char *oldname, const char *newname) @@ -161,9 +171,9 @@ static int skel_rename(vfs_handle_struct *handle, const char *oldname, const ch return vfswrap_rename(NULL, oldname, newname); } -static int skel_fsync(vfs_handle_struct *handle, files_struct *fsp, int fd) +static int skel_fsync(vfs_handle_struct *handle, files_struct *fsp) { - return vfswrap_fsync(NULL, fsp, fd); + return vfswrap_fsync(NULL, fsp); } static int skel_stat(vfs_handle_struct *handle, const char *fname, SMB_STRUCT_STAT *sbuf) @@ -171,9 +181,9 @@ static int skel_stat(vfs_handle_struct *handle, const char *fname, SMB_STRUCT_S return vfswrap_stat(NULL, fname, sbuf); } -static int skel_fstat(vfs_handle_struct *handle, files_struct *fsp, int fd, SMB_STRUCT_STAT *sbuf) +static int skel_fstat(vfs_handle_struct *handle, files_struct *fsp, SMB_STRUCT_STAT *sbuf) { - return vfswrap_fstat(NULL, fsp, fd, sbuf); + return vfswrap_fstat(NULL, fsp, sbuf); } static int skel_lstat(vfs_handle_struct *handle, const char *path, SMB_STRUCT_STAT *sbuf) @@ -191,9 +201,9 @@ static int skel_chmod(vfs_handle_struct *handle, const char *path, mode_t mode) return vfswrap_chmod(NULL, path, mode); } -static int skel_fchmod(vfs_handle_struct *handle, files_struct *fsp, int fd, mode_t mode) +static int skel_fchmod(vfs_handle_struct *handle, files_struct *fsp, mode_t mode) { - return vfswrap_fchmod(NULL, fsp, fd, mode); + return vfswrap_fchmod(NULL, fsp, mode); } static int skel_chown(vfs_handle_struct *handle, const char *path, uid_t uid, gid_t gid) @@ -201,9 +211,14 @@ static int skel_chown(vfs_handle_struct *handle, const char *path, uid_t uid, g return vfswrap_chown(NULL, path, uid, gid); } -static int skel_fchown(vfs_handle_struct *handle, files_struct *fsp, int fd, uid_t uid, gid_t gid) +static int skel_fchown(vfs_handle_struct *handle, files_struct *fsp, uid_t uid, gid_t gid) { - return vfswrap_fchown(NULL, fsp, fd, uid, gid); + return vfswrap_fchown(NULL, fsp, uid, gid); +} + +static int skel_lchown(vfs_handle_struct *handle, const char *path, uid_t uid, gid_t gid) +{ + return vfswrap_lchown(NULL, path, uid, gid); } static int skel_chdir(vfs_handle_struct *handle, const char *path) @@ -221,19 +236,19 @@ static int skel_ntimes(vfs_handle_struct *handle, const char *path, const struc return vfswrap_ntimes(NULL, path, ts); } -static int skel_ftruncate(vfs_handle_struct *handle, files_struct *fsp, int fd, SMB_OFF_T offset) +static int skel_ftruncate(vfs_handle_struct *handle, files_struct *fsp, SMB_OFF_T offset) { - return vfswrap_ftruncate(NULL, fsp, fd, offset); + return vfswrap_ftruncate(NULL, fsp, offset); } -static BOOL skel_lock(vfs_handle_struct *handle, files_struct *fsp, int fd, int op, SMB_OFF_T offset, SMB_OFF_T count, int type) +static bool skel_lock(vfs_handle_struct *handle, files_struct *fsp, int op, SMB_OFF_T offset, SMB_OFF_T count, int type) { - return vfswrap_lock(NULL, fsp, fd, op, offset, count, type); + return vfswrap_lock(NULL, fsp, op, offset, count, type); } -static BOOL skel_getlock(vfs_handle_struct *handle, files_struct *fsp, int fd, SMB_OFF_T *poffset, SMB_OFF_T *pcount, int *ptype, pid_t *ppid) +static bool skel_getlock(vfs_handle_struct *handle, files_struct *fsp, SMB_OFF_T *poffset, SMB_OFF_T *pcount, int *ptype, pid_t *ppid) { - return vfswrap_getlock(NULL, fsp, fd, poffset, pcount, ptype, ppid); + return vfswrap_getlock(NULL, fsp, poffset, pcount, ptype, ppid); } static int skel_symlink(vfs_handle_struct *handle, const char *oldpath, const char *newpath) @@ -276,8 +291,17 @@ static int skel_chflags(vfs_handle_struct *handle, const char *path, uint flags return -1; } +static struct file_id skel_file_id_create(vfs_handle_struct *handle, + SMB_DEV_T dev, SMB_INO_T inode) +{ + struct file_id id_zero; + ZERO_STRUCT(id_zero); + errno = ENOSYS; + return id_zero; +} + static size_t skel_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp, - int fd, uint32 security_info, SEC_DESC **ppdesc) + uint32 security_info, SEC_DESC **ppdesc) { errno = ENOSYS; return 0; @@ -290,18 +314,18 @@ static size_t skel_get_nt_acl(vfs_handle_struct *handle, files_struct *fsp, return 0; } -static BOOL skel_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp, int - fd, uint32 security_info_sent, SEC_DESC *psd) +static NTSTATUS skel_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp, + uint32 security_info_sent, SEC_DESC *psd) { errno = ENOSYS; - return False; + return NT_STATUS_NOT_IMPLEMENTED; } -static BOOL skel_set_nt_acl(vfs_handle_struct *handle, files_struct *fsp, const +static NTSTATUS skel_set_nt_acl(vfs_handle_struct *handle, files_struct *fsp, const char *name, uint32 security_info_sent, SEC_DESC *psd) { errno = ENOSYS; - return False; + return NT_STATUS_NOT_IMPLEMENTED; } static int skel_chmod_acl(vfs_handle_struct *handle, const char *name, mode_t mode) @@ -310,7 +334,7 @@ static int skel_chmod_acl(vfs_handle_struct *handle, const char *name, mode_t m return -1; } -static int skel_fchmod_acl(vfs_handle_struct *handle, files_struct *fsp, int fd, mode_t mode) +static int skel_fchmod_acl(vfs_handle_struct *handle, files_struct *fsp, mode_t mode) { errno = ENOSYS; return -1; @@ -346,7 +370,7 @@ static SMB_ACL_T skel_sys_acl_get_file(vfs_handle_struct *handle, const char *p return NULL; } -static SMB_ACL_T skel_sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp, int fd) +static SMB_ACL_T skel_sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp) { errno = ENOSYS; return NULL; @@ -412,7 +436,7 @@ static int skel_sys_acl_set_file(vfs_handle_struct *handle, const char *name, S return -1; } -static int skel_sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp, int fd, SMB_ACL_T theacl) +static int skel_sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp, SMB_ACL_T theacl) { errno = ENOSYS; return -1; @@ -461,7 +485,7 @@ size) return -1; } -static ssize_t skel_fgetxattr(vfs_handle_struct *handle, struct files_struct *fsp,int fd, const char *name, void *value, size_t size) +static ssize_t skel_fgetxattr(vfs_handle_struct *handle, struct files_struct *fsp, const char *name, void *value, size_t size) { errno = ENOSYS; return -1; @@ -479,7 +503,7 @@ static ssize_t skel_llistxattr(vfs_handle_struct *handle, const char *path, char return -1; } -static ssize_t skel_flistxattr(vfs_handle_struct *handle, struct files_struct *fsp,int fd, char *list, size_t size) +static ssize_t skel_flistxattr(vfs_handle_struct *handle, struct files_struct *fsp, char *list, size_t size) { errno = ENOSYS; return -1; @@ -497,7 +521,7 @@ static int skel_lremovexattr(vfs_handle_struct *handle, const char *path, const return -1; } -static int skel_fremovexattr(vfs_handle_struct *handle, struct files_struct *fsp,int fd, const char *name) +static int skel_fremovexattr(vfs_handle_struct *handle, struct files_struct *fsp, const char *name) { errno = ENOSYS; return -1; @@ -515,7 +539,7 @@ static int skel_lsetxattr(vfs_handle_struct *handle, const char *path, const cha return -1; } -static int skel_fsetxattr(vfs_handle_struct *handle, struct files_struct *fsp,int fd, const char *name, const void *value, size_t size, int flags) +static int skel_fsetxattr(vfs_handle_struct *handle, struct files_struct *fsp, const char *name, const void *value, size_t size, int flags) { errno = ENOSYS; return -1; @@ -536,9 +560,9 @@ static ssize_t skel_aio_return(struct vfs_handle_struct *handle, struct files_st return vfswrap_aio_return(NULL, fsp, aiocb); } -static int skel_aio_cancel(struct vfs_handle_struct *handle, struct files_struct *fsp, int fd, SMB_STRUCT_AIOCB *aiocb) +static int skel_aio_cancel(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb) { - return vfswrap_aio_cancel(NULL, fsp, fd, aiocb); + return vfswrap_aio_cancel(NULL, fsp, aiocb); } static int skel_aio_error(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb) @@ -556,6 +580,21 @@ static int skel_aio_suspend(struct vfs_handle_struct *handle, struct files_struc return vfswrap_aio_suspend(NULL, fsp, aiocb, n, ts); } +static bool skel_aio_force(struct vfs_handle_struct *handle, struct files_struct *fsp) +{ + return vfswrap_aio_force(NULL, fsp); +} + +static bool skel_is_offline(struct vfs_handle_struct *handle, const char *path, SMB_STRUCT_STAT *sbuf) +{ + return vfswrap_is_offline(NULL, path, sbuf); +} + +static int skel_set_offline(struct vfs_handle_struct *handle, const char *path) +{ + return vfswrap_set_offline(NULL, path); +} + /* VFS operations structure */ static vfs_op_tuple skel_op_tuples[] = { @@ -590,6 +629,8 @@ static vfs_op_tuple skel_op_tuples[] = { {SMB_VFS_OP(skel_write), SMB_VFS_OP_WRITE, SMB_VFS_LAYER_OPAQUE}, {SMB_VFS_OP(skel_pwrite), SMB_VFS_OP_PWRITE, SMB_VFS_LAYER_OPAQUE}, {SMB_VFS_OP(skel_lseek), SMB_VFS_OP_LSEEK, SMB_VFS_LAYER_OPAQUE}, + {SMB_VFS_OP(skel_sendfile), SMB_VFS_OP_SENDFILE, SMB_VFS_LAYER_OPAQUE}, + {SMB_VFS_OP(skel_recvfile), SMB_VFS_OP_RECVFILE, SMB_VFS_LAYER_OPAQUE}, {SMB_VFS_OP(skel_rename), SMB_VFS_OP_RENAME, SMB_VFS_LAYER_OPAQUE}, {SMB_VFS_OP(skel_fsync), SMB_VFS_OP_FSYNC, SMB_VFS_LAYER_OPAQUE}, {SMB_VFS_OP(skel_stat), SMB_VFS_OP_STAT, SMB_VFS_LAYER_OPAQUE}, @@ -600,6 +641,7 @@ static vfs_op_tuple skel_op_tuples[] = { {SMB_VFS_OP(skel_fchmod), SMB_VFS_OP_FCHMOD, SMB_VFS_LAYER_OPAQUE}, {SMB_VFS_OP(skel_chown), SMB_VFS_OP_CHOWN, SMB_VFS_LAYER_OPAQUE}, {SMB_VFS_OP(skel_fchown), SMB_VFS_OP_FCHOWN, SMB_VFS_LAYER_OPAQUE}, + {SMB_VFS_OP(skel_lchown), SMB_VFS_OP_LCHOWN, SMB_VFS_LAYER_OPAQUE}, {SMB_VFS_OP(skel_chdir), SMB_VFS_OP_CHDIR, SMB_VFS_LAYER_OPAQUE}, {SMB_VFS_OP(skel_getwd), SMB_VFS_OP_GETWD, SMB_VFS_LAYER_OPAQUE}, {SMB_VFS_OP(skel_ntimes), SMB_VFS_OP_NTIMES, SMB_VFS_LAYER_OPAQUE}, @@ -613,8 +655,7 @@ static vfs_op_tuple skel_op_tuples[] = { {SMB_VFS_OP(skel_realpath), SMB_VFS_OP_REALPATH, SMB_VFS_LAYER_OPAQUE}, {SMB_VFS_OP(skel_notify_watch), SMB_VFS_OP_NOTIFY_WATCH, SMB_VFS_LAYER_OPAQUE}, {SMB_VFS_OP(skel_chflags), SMB_VFS_OP_CHFLAGS, SMB_VFS_LAYER_OPAQUE}, - - + {SMB_VFS_OP(skel_file_id_create), SMB_VFS_OP_FILE_ID_CREATE, SMB_VFS_LAYER_OPAQUE}, /* NT File ACL operations */ @@ -650,7 +691,7 @@ static vfs_op_tuple skel_op_tuples[] = { {SMB_VFS_OP(skel_sys_acl_free_text), SMB_VFS_OP_SYS_ACL_FREE_TEXT, SMB_VFS_LAYER_OPAQUE}, {SMB_VFS_OP(skel_sys_acl_free_acl), SMB_VFS_OP_SYS_ACL_FREE_ACL, SMB_VFS_LAYER_OPAQUE}, {SMB_VFS_OP(skel_sys_acl_free_qualifier), SMB_VFS_OP_SYS_ACL_FREE_QUALIFIER, SMB_VFS_LAYER_OPAQUE}, - + /* EA operations. */ {SMB_VFS_OP(skel_getxattr), SMB_VFS_OP_GETXATTR, SMB_VFS_LAYER_OPAQUE}, {SMB_VFS_OP(skel_lgetxattr), SMB_VFS_OP_LGETXATTR, SMB_VFS_LAYER_OPAQUE}, @@ -673,6 +714,11 @@ static vfs_op_tuple skel_op_tuples[] = { {SMB_VFS_OP(skel_aio_error), SMB_VFS_OP_AIO_ERROR, SMB_VFS_LAYER_OPAQUE}, {SMB_VFS_OP(skel_aio_fsync), SMB_VFS_OP_AIO_FSYNC, SMB_VFS_LAYER_OPAQUE}, {SMB_VFS_OP(skel_aio_suspend), SMB_VFS_OP_AIO_SUSPEND, SMB_VFS_LAYER_OPAQUE}, + {SMB_VFS_OP(skel_aio_force), SMB_VFS_OP_AIO_FORCE, SMB_VFS_LAYER_OPAQUE}, + + /* offline operations */ + {SMB_VFS_OP(skel_is_offline), SMB_VFS_OP_IS_OFFLINE, SMB_VFS_LAYER_OPAQUE}, + {SMB_VFS_OP(skel_set_offline), SMB_VFS_OP_SET_OFFLINE, SMB_VFS_LAYER_OPAQUE}, {NULL, SMB_VFS_OP_NOOP, SMB_VFS_LAYER_NOOP} }; diff --git a/examples/VFS/skel_transparent.c b/examples/VFS/skel_transparent.c index 2efb3d54a7..7102d4d4db 100644 --- a/examples/VFS/skel_transparent.c +++ b/examples/VFS/skel_transparent.c @@ -8,7 +8,7 @@ * * 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 + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, @@ -17,8 +17,7 @@ * 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. + * along with this program; if not, see <http://www.gnu.org/licenses/>. */ @@ -48,7 +47,7 @@ static void skel_disconnect(vfs_handle_struct *handle) } static SMB_BIG_UINT skel_disk_free(vfs_handle_struct *handle, const char *path, - BOOL small_query, SMB_BIG_UINT *bsize, + bool small_query, SMB_BIG_UINT *bsize, SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize) { return SMB_VFS_NEXT_DISK_FREE(handle, path, small_query, bsize, @@ -65,7 +64,7 @@ static int skel_set_quota(vfs_handle_struct *handle, enum SMB_QUOTA_TYPE qtype, return SMB_VFS_NEXT_SET_QUOTA(handle, qtype, id, dq); } -static int skel_get_shadow_copy_data(vfs_handle_struct *handle, files_struct *fsp, SHADOW_COPY_DATA *shadow_copy_data, BOOL labels) +static int skel_get_shadow_copy_data(vfs_handle_struct *handle, files_struct *fsp, SHADOW_COPY_DATA *shadow_copy_data, bool labels) { return SMB_VFS_NEXT_GET_SHADOW_COPY_DATA(handle, fsp, shadow_copy_data, labels); } @@ -120,34 +119,44 @@ static int skel_open(vfs_handle_struct *handle, const char *fname, files_struct return SMB_VFS_NEXT_OPEN(handle, fname, fsp, flags, mode); } -static int skel_close(vfs_handle_struct *handle, files_struct *fsp, int fd) +static int skel_close(vfs_handle_struct *handle, files_struct *fsp) { - return SMB_VFS_NEXT_CLOSE(handle, fsp, fd); + return SMB_VFS_NEXT_CLOSE(handle, fsp); } -static ssize_t skel_read(vfs_handle_struct *handle, files_struct *fsp, int fd, void *data, size_t n) +static ssize_t skel_read(vfs_handle_struct *handle, files_struct *fsp, void *data, size_t n) { - return SMB_VFS_NEXT_READ(handle, fsp, fd, data, n); + return SMB_VFS_NEXT_READ(handle, fsp, data, n); } -static ssize_t skel_pread(vfs_handle_struct *handle, files_struct *fsp, int fd, void *data, size_t n, SMB_OFF_T offset) +static ssize_t skel_pread(vfs_handle_struct *handle, files_struct *fsp, void *data, size_t n, SMB_OFF_T offset) { - return SMB_VFS_NEXT_PREAD(handle, fsp, fd, data, n, offset); + return SMB_VFS_NEXT_PREAD(handle, fsp, data, n, offset); } -static ssize_t skel_write(vfs_handle_struct *handle, files_struct *fsp, int fd, const void *data, size_t n) +static ssize_t skel_write(vfs_handle_struct *handle, files_struct *fsp, const void *data, size_t n) { - return SMB_VFS_NEXT_WRITE(handle, fsp, fd, data, n); + return SMB_VFS_NEXT_WRITE(handle, fsp, data, n); } -static ssize_t skel_pwrite(vfs_handle_struct *handle, files_struct *fsp, int fd, const void *data, size_t n, SMB_OFF_T offset) +static ssize_t skel_pwrite(vfs_handle_struct *handle, files_struct *fsp, const void *data, size_t n, SMB_OFF_T offset) { - return SMB_VFS_NEXT_PWRITE(handle, fsp, fd, data, n, offset); + return SMB_VFS_NEXT_PWRITE(handle, fsp, data, n, offset); } -static SMB_OFF_T skel_lseek(vfs_handle_struct *handle, files_struct *fsp, int filedes, SMB_OFF_T offset, int whence) +static SMB_OFF_T skel_lseek(vfs_handle_struct *handle, files_struct *fsp, SMB_OFF_T offset, int whence) { - return SMB_VFS_NEXT_LSEEK(handle, fsp, filedes, offset, whence); + return SMB_VFS_NEXT_LSEEK(handle, fsp, offset, whence); +} + +static ssize_t skel_sendfile(vfs_handle_struct *handle, int tofd, files_struct *fromfsp, const DATA_BLOB *hdr, SMB_OFF_T offset, size_t n) +{ + return SMB_VFS_NEXT_SENDFILE(handle, tofd, fromfsp, hdr, offset, n); +} + +static ssize_t skel_recvfile(vfs_handle_struct *handle, int fromfd, files_struct *tofsp, SMB_OFF_T offset, size_t n) +{ + return SMB_VFS_NEXT_RECVFILE(handle, fromfd, tofsp, offset, n); } static int skel_rename(vfs_handle_struct *handle, const char *oldname, const char *newname) @@ -155,9 +164,9 @@ static int skel_rename(vfs_handle_struct *handle, const char *oldname, const ch return SMB_VFS_NEXT_RENAME(handle, oldname, newname); } -static int skel_fsync(vfs_handle_struct *handle, files_struct *fsp, int fd) +static int skel_fsync(vfs_handle_struct *handle, files_struct *fsp) { - return SMB_VFS_NEXT_FSYNC(handle, fsp, fd); + return SMB_VFS_NEXT_FSYNC(handle, fsp); } static int skel_stat(vfs_handle_struct *handle, const char *fname, SMB_STRUCT_STAT *sbuf) @@ -165,9 +174,9 @@ static int skel_stat(vfs_handle_struct *handle, const char *fname, SMB_STRUCT_S return SMB_VFS_NEXT_STAT(handle, fname, sbuf); } -static int skel_fstat(vfs_handle_struct *handle, files_struct *fsp, int fd, SMB_STRUCT_STAT *sbuf) +static int skel_fstat(vfs_handle_struct *handle, files_struct *fsp, SMB_STRUCT_STAT *sbuf) { - return SMB_VFS_NEXT_FSTAT(handle, fsp, fd, sbuf); + return SMB_VFS_NEXT_FSTAT(handle, fsp, sbuf); } static int skel_lstat(vfs_handle_struct *handle, const char *path, SMB_STRUCT_STAT *sbuf) @@ -185,9 +194,9 @@ static int skel_chmod(vfs_handle_struct *handle, const char *path, mode_t mode) return SMB_VFS_NEXT_CHMOD(handle, path, mode); } -static int skel_fchmod(vfs_handle_struct *handle, files_struct *fsp, int fd, mode_t mode) +static int skel_fchmod(vfs_handle_struct *handle, files_struct *fsp, mode_t mode) { - return SMB_VFS_NEXT_FCHMOD(handle, fsp, fd, mode); + return SMB_VFS_NEXT_FCHMOD(handle, fsp, mode); } static int skel_chown(vfs_handle_struct *handle, const char *path, uid_t uid, gid_t gid) @@ -195,9 +204,14 @@ static int skel_chown(vfs_handle_struct *handle, const char *path, uid_t uid, g return SMB_VFS_NEXT_CHOWN(handle, path, uid, gid); } -static int skel_fchown(vfs_handle_struct *handle, files_struct *fsp, int fd, uid_t uid, gid_t gid) +static int skel_fchown(vfs_handle_struct *handle, files_struct *fsp, uid_t uid, gid_t gid) { - return SMB_VFS_NEXT_FCHOWN(handle, fsp, fd, uid, gid); + return SMB_VFS_NEXT_FCHOWN(handle, fsp, uid, gid); +} + +static int skel_lchown(vfs_handle_struct *handle, const char *path, uid_t uid, gid_t gid) +{ + return SMB_VFS_NEXT_LCHOWN(handle, path, uid, gid); } static int skel_chdir(vfs_handle_struct *handle, const char *path) @@ -215,19 +229,19 @@ static int skel_ntimes(vfs_handle_struct *handle, const char *path, const struc return SMB_VFS_NEXT_NTIMES(handle, path, ts); } -static int skel_ftruncate(vfs_handle_struct *handle, files_struct *fsp, int fd, SMB_OFF_T offset) +static int skel_ftruncate(vfs_handle_struct *handle, files_struct *fsp, SMB_OFF_T offset) { - return SMB_VFS_NEXT_FTRUNCATE(handle, fsp, fd, offset); + return SMB_VFS_NEXT_FTRUNCATE(handle, fsp, offset); } -static BOOL skel_lock(vfs_handle_struct *handle, files_struct *fsp, int fd, int op, SMB_OFF_T offset, SMB_OFF_T count, int type) +static bool skel_lock(vfs_handle_struct *handle, files_struct *fsp, int op, SMB_OFF_T offset, SMB_OFF_T count, int type) { - return SMB_VFS_NEXT_LOCK(handle, fsp, fd, op, offset, count, type); + return SMB_VFS_NEXT_LOCK(handle, fsp, op, offset, count, type); } -static BOOL skel_getlock(vfs_handle_struct *handle, files_struct *fsp, int fd, SMB_OFF_T *poffset, SMB_OFF_T *pcount, int *ptype, pid_t *ppid) +static bool skel_getlock(vfs_handle_struct *handle, files_struct *fsp, SMB_OFF_T *poffset, SMB_OFF_T *pcount, int *ptype, pid_t *ppid) { - return SMB_VFS_NEXT_GETLOCK(handle, fsp, fd, poffset, pcount, ptype, ppid); + return SMB_VFS_NEXT_GETLOCK(handle, fsp, poffset, pcount, ptype, ppid); } static int skel_symlink(vfs_handle_struct *handle, const char *oldpath, const char *newpath) @@ -269,25 +283,31 @@ static int skel_chflags(vfs_handle_struct *handle, const char *path, uint flags return SMB_VFS_NEXT_CHFLAGS(handle, path, flags); } -static size_t skel_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp, - int fd, uint32 security_info, SEC_DESC **ppdesc) +static struct file_id skel_file_id_create(vfs_handle_struct *handle, + SMB_DEV_T dev, SMB_INO_T inode) +{ + return SMB_VFS_NEXT_FILE_ID_CREATE(handle, dev, inode); +} + +static NTSTATUS skel_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp, + uint32 security_info, SEC_DESC **ppdesc) { - return SMB_VFS_NEXT_FGET_NT_ACL(handle, fsp, fd, security_info, ppdesc); + return SMB_VFS_NEXT_FGET_NT_ACL(handle, fsp, security_info, ppdesc); } -static size_t skel_get_nt_acl(vfs_handle_struct *handle, files_struct *fsp, +static NTSTATUS skel_get_nt_acl(vfs_handle_struct *handle, const char *name, uint32 security_info, SEC_DESC **ppdesc) { - return SMB_VFS_NEXT_GET_NT_ACL(handle, fsp, name, security_info, ppdesc); + return SMB_VFS_NEXT_GET_NT_ACL(handle, name, security_info, ppdesc); } -static BOOL skel_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp, - int fd, uint32 security_info_sent, SEC_DESC *psd) +static NTSTATUS skel_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp, + uint32 security_info_sent, SEC_DESC *psd) { - return SMB_VFS_NEXT_FSET_NT_ACL(handle, fsp, fd, security_info_sent, psd); + return SMB_VFS_NEXT_FSET_NT_ACL(handle, fsp, security_info_sent, psd); } -static BOOL skel_set_nt_acl(vfs_handle_struct *handle, files_struct *fsp, +static NTSTATUS skel_set_nt_acl(vfs_handle_struct *handle, files_struct *fsp, const char *name, uint32 security_info_sent, SEC_DESC *psd) { return SMB_VFS_NEXT_SET_NT_ACL(handle, fsp, name, security_info_sent, psd); @@ -303,14 +323,14 @@ static int skel_chmod_acl(vfs_handle_struct *handle, const char *name, mode_t m return SMB_VFS_NEXT_CHMOD_ACL(handle, name, mode); } -static int skel_fchmod_acl(vfs_handle_struct *handle, files_struct *fsp, int fd, mode_t mode) +static int skel_fchmod_acl(vfs_handle_struct *handle, files_struct *fsp, mode_t mode) { /* If the underlying VFS doesn't have ACL support... */ if (!handle->vfs_next.ops.fchmod_acl) { errno = ENOSYS; return -1; } - return SMB_VFS_NEXT_FCHMOD_ACL(handle, fsp, fd, mode); + return SMB_VFS_NEXT_FCHMOD_ACL(handle, fsp, mode); } static int skel_sys_acl_get_entry(vfs_handle_struct *handle, SMB_ACL_T theacl, int entry_id, SMB_ACL_ENTRY_T *entry_p) @@ -338,9 +358,9 @@ static SMB_ACL_T skel_sys_acl_get_file(vfs_handle_struct *handle, const char *p return SMB_VFS_NEXT_SYS_ACL_GET_FILE(handle, path_p, type); } -static SMB_ACL_T skel_sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp, int fd) +static SMB_ACL_T skel_sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp) { - return SMB_VFS_NEXT_SYS_ACL_GET_FD(handle, fsp, fd); + return SMB_VFS_NEXT_SYS_ACL_GET_FD(handle, fsp); } static int skel_sys_acl_clear_perms(vfs_handle_struct *handle, SMB_ACL_PERMSET_T permset) @@ -393,9 +413,9 @@ static int skel_sys_acl_set_file(vfs_handle_struct *handle, const char *name, S return SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle, name, acltype, theacl); } -static int skel_sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp, int fd, SMB_ACL_T theacl) +static int skel_sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp, SMB_ACL_T theacl) { - return SMB_VFS_NEXT_SYS_ACL_SET_FD(handle, fsp, fd, theacl); + return SMB_VFS_NEXT_SYS_ACL_SET_FD(handle, fsp, theacl); } static int skel_sys_acl_delete_def_file(vfs_handle_struct *handle, const char *path) @@ -434,9 +454,9 @@ size) return SMB_VFS_NEXT_LGETXATTR(handle, path, name, value, size); } -static ssize_t skel_fgetxattr(vfs_handle_struct *handle, struct files_struct *fsp,int fd, const char *name, void *value, size_t size) +static ssize_t skel_fgetxattr(vfs_handle_struct *handle, struct files_struct *fsp, const char *name, void *value, size_t size) { - return SMB_VFS_NEXT_FGETXATTR(handle, fsp, fd, name, value, size); + return SMB_VFS_NEXT_FGETXATTR(handle, fsp, name, value, size); } static ssize_t skel_listxattr(vfs_handle_struct *handle, const char *path, char *list, size_t size) @@ -449,9 +469,9 @@ static ssize_t skel_llistxattr(vfs_handle_struct *handle, const char *path, char return SMB_VFS_NEXT_LLISTXATTR(handle, path, list, size); } -static ssize_t skel_flistxattr(vfs_handle_struct *handle, struct files_struct *fsp,int fd, char *list, size_t size) +static ssize_t skel_flistxattr(vfs_handle_struct *handle, struct files_struct *fsp, char *list, size_t size) { - return SMB_VFS_NEXT_FLISTXATTR(handle, fsp, fd, list, size); + return SMB_VFS_NEXT_FLISTXATTR(handle, fsp, list, size); } static int skel_removexattr(vfs_handle_struct *handle, const char *path, const char *name) @@ -464,9 +484,9 @@ static int skel_lremovexattr(vfs_handle_struct *handle, const char *path, const return SMB_VFS_NEXT_LREMOVEXATTR(handle, path, name); } -static int skel_fremovexattr(vfs_handle_struct *handle, struct files_struct *fsp,int fd, const char *name) +static int skel_fremovexattr(vfs_handle_struct *handle, struct files_struct *fsp, const char *name) { - return SMB_VFS_NEXT_FREMOVEXATTR(handle, fsp, fd, name); + return SMB_VFS_NEXT_FREMOVEXATTR(handle, fsp, name); } static int skel_setxattr(vfs_handle_struct *handle, const char *path, const char *name, const void *value, size_t size, int flags) @@ -479,9 +499,9 @@ static int skel_lsetxattr(vfs_handle_struct *handle, const char *path, const cha return SMB_VFS_NEXT_LSETXATTR(handle, path, name, value, size, flags); } -static int skel_fsetxattr(vfs_handle_struct *handle, struct files_struct *fsp,int fd, const char *name, const void *value, size_t size, int flags) +static int skel_fsetxattr(vfs_handle_struct *handle, struct files_struct *fsp, const char *name, const void *value, size_t size, int flags) { - return SMB_VFS_NEXT_FSETXATTR(handle, fsp, fd, name, value, size, flags); + return SMB_VFS_NEXT_FSETXATTR(handle, fsp, name, value, size, flags); } static int skel_aio_read(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb) @@ -499,9 +519,9 @@ static ssize_t skel_aio_return(struct vfs_handle_struct *handle, struct files_st return SMB_VFS_NEXT_AIO_RETURN(handle, fsp, aiocb); } -static int skel_aio_cancel(struct vfs_handle_struct *handle, struct files_struct *fsp, int fd, SMB_STRUCT_AIOCB *aiocb) +static int skel_aio_cancel(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb) { - return SMB_VFS_NEXT_AIO_CANCEL(handle, fsp, fd, aiocb); + return SMB_VFS_NEXT_AIO_CANCEL(handle, fsp, aiocb); } static int skel_aio_error(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb) @@ -519,6 +539,26 @@ static int skel_aio_suspend(struct vfs_handle_struct *handle, struct files_struc return SMB_VFS_NEXT_AIO_SUSPEND(handle, fsp, aiocb, n, ts); } +static bool skel_aio_force(struct vfs_handle_struct *handle, struct files_struct *fsp) +{ + return SMB_VFS_NEXT_AIO_FORCE(handle, fsp); +} + +static bool skel_is_offline(struct vfs_handle_struct *handle, const char *path, SMB_STRUCT_STAT *sbuf) +{ + return SMB_VFS_NEXT_IS_OFFLINE(handle, path, sbuf); +} + +static int skel_set_offline(struct vfs_handle_struct *handle, const char *path) +{ + return SMB_VFS_NEXT_SET_OFFLINE(handle, path); +} + +static bool skel_is_remotestorage(struct vfs_handle_struct *handle, const char *path) +{ + return SMB_VFS_NEXT_IS_REMOTESTORAGE(handle, path); +} + /* VFS operations structure */ static vfs_op_tuple skel_op_tuples[] = { @@ -551,6 +591,8 @@ static vfs_op_tuple skel_op_tuples[] = { {SMB_VFS_OP(skel_read), SMB_VFS_OP_READ, SMB_VFS_LAYER_TRANSPARENT}, {SMB_VFS_OP(skel_write), SMB_VFS_OP_WRITE, SMB_VFS_LAYER_TRANSPARENT}, {SMB_VFS_OP(skel_lseek), SMB_VFS_OP_LSEEK, SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(skel_sendfile), SMB_VFS_OP_SENDFILE, SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(skel_recvfile), SMB_VFS_OP_RECVFILE, SMB_VFS_LAYER_TRANSPARENT}, {SMB_VFS_OP(skel_rename), SMB_VFS_OP_RENAME, SMB_VFS_LAYER_TRANSPARENT}, {SMB_VFS_OP(skel_fsync), SMB_VFS_OP_FSYNC, SMB_VFS_LAYER_TRANSPARENT}, {SMB_VFS_OP(skel_stat), SMB_VFS_OP_STAT, SMB_VFS_LAYER_TRANSPARENT}, @@ -561,6 +603,7 @@ static vfs_op_tuple skel_op_tuples[] = { {SMB_VFS_OP(skel_fchmod), SMB_VFS_OP_FCHMOD, SMB_VFS_LAYER_TRANSPARENT}, {SMB_VFS_OP(skel_chown), SMB_VFS_OP_CHOWN, SMB_VFS_LAYER_TRANSPARENT}, {SMB_VFS_OP(skel_fchown), SMB_VFS_OP_FCHOWN, SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(skel_lchown), SMB_VFS_OP_LCHOWN, SMB_VFS_LAYER_TRANSPARENT}, {SMB_VFS_OP(skel_chdir), SMB_VFS_OP_CHDIR, SMB_VFS_LAYER_TRANSPARENT}, {SMB_VFS_OP(skel_getwd), SMB_VFS_OP_GETWD, SMB_VFS_LAYER_TRANSPARENT}, {SMB_VFS_OP(skel_ntimes), SMB_VFS_OP_NTIMES, SMB_VFS_LAYER_TRANSPARENT}, @@ -574,6 +617,7 @@ static vfs_op_tuple skel_op_tuples[] = { {SMB_VFS_OP(skel_realpath), SMB_VFS_OP_REALPATH, SMB_VFS_LAYER_TRANSPARENT}, {SMB_VFS_OP(skel_notify_watch), SMB_VFS_OP_NOTIFY_WATCH, SMB_VFS_LAYER_TRANSPARENT}, {SMB_VFS_OP(skel_chflags), SMB_VFS_OP_CHFLAGS, SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(skel_file_id_create), SMB_VFS_OP_FILE_ID_CREATE, SMB_VFS_LAYER_TRANSPARENT}, /* NT File ACL operations */ @@ -609,7 +653,7 @@ static vfs_op_tuple skel_op_tuples[] = { {SMB_VFS_OP(skel_sys_acl_free_text), SMB_VFS_OP_SYS_ACL_FREE_TEXT, SMB_VFS_LAYER_TRANSPARENT}, {SMB_VFS_OP(skel_sys_acl_free_acl), SMB_VFS_OP_SYS_ACL_FREE_ACL, SMB_VFS_LAYER_TRANSPARENT}, {SMB_VFS_OP(skel_sys_acl_free_qualifier), SMB_VFS_OP_SYS_ACL_FREE_QUALIFIER, SMB_VFS_LAYER_TRANSPARENT}, - + /* EA operations. */ {SMB_VFS_OP(skel_getxattr), SMB_VFS_OP_GETXATTR, SMB_VFS_LAYER_TRANSPARENT}, {SMB_VFS_OP(skel_lgetxattr), SMB_VFS_OP_LGETXATTR, SMB_VFS_LAYER_TRANSPARENT}, @@ -632,6 +676,11 @@ static vfs_op_tuple skel_op_tuples[] = { {SMB_VFS_OP(skel_aio_error), SMB_VFS_OP_AIO_ERROR, SMB_VFS_LAYER_TRANSPARENT}, {SMB_VFS_OP(skel_aio_fsync), SMB_VFS_OP_AIO_FSYNC, SMB_VFS_LAYER_TRANSPARENT}, {SMB_VFS_OP(skel_aio_suspend), SMB_VFS_OP_AIO_SUSPEND, SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(skel_aio_force), SMB_VFS_OP_AIO_FORCE, SMB_VFS_LAYER_TRANSPARENT}, + + /* offline operations */ + {SMB_VFS_OP(skel_is_offline), SMB_VFS_OP_IS_OFFLINE, SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(skel_set_offline), SMB_VFS_OP_SET_OFFLINE, SMB_VFS_LAYER_TRANSPARENT}, {NULL, SMB_VFS_OP_NOOP, SMB_VFS_LAYER_NOOP} }; diff --git a/examples/auth/auth_skel.c b/examples/auth/auth_skel.c index bcc3bdd96a..e6cbd73968 100644 --- a/examples/auth/auth_skel.c +++ b/examples/auth/auth_skel.c @@ -6,7 +6,7 @@ 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 + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -15,8 +15,7 @@ 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. + along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "includes.h" diff --git a/examples/libmsrpc/cacusermgr/Makefile b/examples/libmsrpc/cacusermgr/Makefile deleted file mode 100644 index ab8bea410e..0000000000 --- a/examples/libmsrpc/cacusermgr/Makefile +++ /dev/null @@ -1,22 +0,0 @@ -CC=gcc -INCLUDES= -I`pwd` -I../../../source/ -I../../../source/include -I../../../source/ubiqx - -DEFS= -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE - -CFLAGS= -g -Wall -ansi $(INCLUDES) - -OBJ= util.o mgr_group.o mgr_user.o - -LDFLAGS=-L. -L../../bin/ -LIBS=../../../source/bin/libmsrpc.so - -all: cacusermgr - -cacusermgr: cacusermgr.o $(OBJ) - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(OBJ) $(LIBS) - -.c.o: - $(CC) $(CFLAGS) -c $< -o $@ - -clean: - rm -f *.o cacusermgr diff --git a/examples/libmsrpc/cacusermgr/cacusermgr.c b/examples/libmsrpc/cacusermgr/cacusermgr.c deleted file mode 100644 index 77dd2505f6..0000000000 --- a/examples/libmsrpc/cacusermgr/cacusermgr.c +++ /dev/null @@ -1,344 +0,0 @@ -/* - * Unix SMB/CIFS implementation. - * cacusermgr main implementation. - * - * Copyright (C) Chris Nicholls 2005 - * - * 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. */ - -#include "cacusermgr.h" - -#define DEFAULT_MENU_LINES 15 - - -void create_menu(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *dom_hnd) { - struct SamCreateUser cu; - struct SamCreateGroup cg; - - fstring in; - fstring tmp; - - if(!hnd || !mem_ctx || !dom_hnd) { - printf("No Handle to SAM.\n"); - return; - } - - /*the menu*/ - in[0] = '\0'; - while(in[0] != 'c' && in[0] != 'C' && in[0] != 'q' && in[0] != 'Q') { - printf("\n"); - printf("[u] Create User\n"); - printf("[g] Create Group\n"); - printf("[m] Create Machine Account\n"); - printf("[c] Cancel\n\n"); - - printf("Command: "); - mgr_getline(in); - - printf("\n"); - - switch(in[0]) { - case 'u': /*create user*/ - case 'U': - ZERO_STRUCT(cu); - cu.in.dom_hnd = dom_hnd; - cu.in.acb_mask = ACB_NORMAL; - - printf("Enter name: "); - mgr_getline(tmp); - cu.in.name = talloc_strdup(mem_ctx, tmp); - - if(!cac_SamCreateUser(hnd, mem_ctx, &cu)) { - printerr("Could not create user.", hnd->status); - } - else { - user_menu(hnd, mem_ctx, dom_hnd, cu.out.user_hnd); - } - - /*this will break the loop and send us back to the main menu*/ - in[0] = 'c'; - break; - - case 'g': /*create group*/ - case 'G': - ZERO_STRUCT(cg); - cg.in.dom_hnd = dom_hnd; - cg.in.access = MAXIMUM_ALLOWED_ACCESS; - - printf("Enter name: "); - mgr_getline(tmp); - cg.in.name = talloc_strdup(mem_ctx, tmp); - - if(!cac_SamCreateGroup(hnd, mem_ctx, &cg)) { - printerr("Could not create group.", hnd->status); - } - else { - group_menu(hnd, mem_ctx, dom_hnd, cg.out.group_hnd); - } - - /*this will break the loop and send us back to the main menu*/ - in[0] = 'c'; - break; - - case 'm': /*create machine account*/ - case 'M': - ZERO_STRUCT(cu); - cu.in.dom_hnd = dom_hnd; - cu.in.acb_mask = ACB_WSTRUST; - - printf("Enter machine name: "); - mgr_getline(tmp); - - /*make sure we have a $ on the end*/ - if(tmp[strlen(tmp) - 1] != '$') - cu.in.name = talloc_asprintf(mem_ctx, "%s$", tmp); - else - cu.in.name = talloc_strdup(mem_ctx, tmp); - - strlower_m(cu.in.name); - - printf("Creating account: %s\n", cu.in.name); - - if(!cac_SamCreateUser(hnd, mem_ctx, &cu)) { - printerr("Could not create account.", hnd->status); - } - else { - user_menu(hnd, mem_ctx, dom_hnd, cu.out.user_hnd); - } - - /*this will break the loop and send us back to the main menu*/ - in[0] = 'c'; - break; - - case 'c': /*cancel*/ - case 'C': - case 'q': - case 'Q': - /*do nothing*/ - break; - - default: - printf("Invalid option\n"); - } - } - - return; -} - -void main_menu(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *dom_hnd) { - fstring in; - - uint32 rid_type = 0; - - struct SamOpenUser openu; - struct SamOpenGroup openg; - struct SamEnumUsers enumu; - struct SamEnumGroups enumg; - struct SamFlush flush; - - char *name = NULL; - uint32 rid = 0; - - if(!hnd || !mem_ctx || !dom_hnd) { - printf("No handle to SAM.\n"); - return; - } - - /*initialize this here and don't worry about it later*/ - ZERO_STRUCT(flush); - flush.in.dom_hnd = dom_hnd; - - in[0] = '\0'; - - /*handle the menu and commands*/ - while(in[0] != 'q' && in[0] != 'Q') { - printf("\n"); - - printf("[o] Open User or Group\n"); - printf("[c] Create Account or Group\n"); - printf("[u] List Users\n"); - printf("[g] List Groups\n"); - printf("[m] List Machine Accounts\n"); - printf("[q] Quit\n\n"); - - printf("Command: "); - - mgr_getline(in); - - printf("\n"); - - switch(in[0]) { - case 'o': /*open user or group*/ - case 'O': - printf("Enter RID or Name: "); - rid_type = rid_or_name(hnd, mem_ctx, dom_hnd, &rid, &name); - - if(rid_type == CAC_USER_RID) { - ZERO_STRUCT(openu); - openu.in.dom_hnd = dom_hnd; - openu.in.rid = rid; - openu.in.access = MAXIMUM_ALLOWED_ACCESS; - - if(!cac_SamOpenUser(hnd, mem_ctx, &openu)) - printerr("Could not open user.", hnd->status); - else { - user_menu(hnd, mem_ctx, dom_hnd, openu.out.user_hnd); - - if(!cac_SamFlush(hnd, mem_ctx, &flush)) { - printerr("Lost handle while flushing SAM.", hnd->status); - /*we want to quit*/ - in[0] = 'q'; - } - } - } - else if(rid_type == CAC_GROUP_RID) { - ZERO_STRUCT(openg); - openg.in.dom_hnd = dom_hnd; - openg.in.rid = rid; - openg.in.access = MAXIMUM_ALLOWED_ACCESS; - - if(!cac_SamOpenGroup(hnd, mem_ctx, &openg)) - printerr("Could not open group.", hnd->status); - else { - group_menu(hnd, mem_ctx, dom_hnd, openg.out.group_hnd); - - if(!cac_SamFlush(hnd, mem_ctx, &flush)) { - printerr("Lost handle while flushing SAM.", hnd->status); - /*we want to quit*/ - in[0] = 'q'; - } - } - } - else { - printf("Unknown RID/Name.\n"); - } - - break; - - case 'c': /*create account/group*/ - case 'C': - create_menu(hnd, mem_ctx, dom_hnd); - if(!cac_SamFlush(hnd, mem_ctx, &flush)) { - printerr("Lost handle while flushing SAM.", hnd->status); - /*we want to quit*/ - in[0] = 'q'; - } - break; - - case 'u': /*list users*/ - case 'U': - ZERO_STRUCT(enumu); - enumu.in.dom_hnd = dom_hnd; - enumu.in.acb_mask = ACB_NORMAL; - - printf("Users:\n"); - while(cac_SamEnumUsers(hnd, mem_ctx, &enumu)) { - print_rid_list(enumu.out.rids, enumu.out.names, enumu.out.num_users); - } - if(CAC_OP_FAILED(hnd->status)) - printerr("Error occured while enumerating users.", hnd->status); - break; - - case 'g': /*list groups*/ - case 'G': - ZERO_STRUCT(enumg); - enumg.in.dom_hnd = dom_hnd; - - while(cac_SamEnumGroups(hnd, mem_ctx, &enumg)) { - print_rid_list( enumg.out.rids, enumg.out.names, enumg.out.num_groups); - } - - if(CAC_OP_FAILED(hnd->status)) - printerr("Error occured while enumerating groups.", hnd->status); - break; - - case 'm': /*list machine accounts*/ - case 'M': - ZERO_STRUCT(enumu); - enumu.in.dom_hnd = dom_hnd; - enumu.in.acb_mask = ACB_WSTRUST; - - printf("Users:\n"); - while(cac_SamEnumUsers(hnd, mem_ctx, &enumu)) { - print_rid_list( enumu.out.rids, enumu.out.names, enumu.out.num_users); - } - if(CAC_OP_FAILED(hnd->status)) - printerr("Error occured while enumerating accounts.", hnd->status); - break; - - case 'q': /*quit*/ - case 'Q': - /*just do nothing*/ - break; - - default: - printf("Invalid Command.\n"); - } - } -} - -int main(int argc, char **argv) { - CacServerHandle *hnd = NULL; - TALLOC_CTX *mem_ctx = NULL; - - struct SamOpenDomain sod; - - mem_ctx = talloc_init("cacusermgr"); - if(!mem_ctx) { - printf("Could not initialize Talloc Context\n"); - exit(-1); - } - - /**first initialize the server handle with what we have*/ - hnd = cac_NewServerHandle(True); - if(!hnd) { - printf("Could not create server handle\n"); - exit(-1); - } - - /*fill in the blanks*/ - if(!process_cmd_line(hnd, mem_ctx, argc, argv)) - usage(); - - if(!cac_Connect(hnd, NULL)) { - printf("Could not connect to server %s. %s\n", hnd->server, nt_errstr(hnd->status)); - exit(-1); - } - - /*open the domain sam*/ - ZERO_STRUCT(sod); - sod.in.access = MAXIMUM_ALLOWED_ACCESS; - - if(!cac_SamOpenDomain(hnd, mem_ctx, &sod)) { - printf("Could not open handle to domain SAM. %s\n", nt_errstr(hnd->status)); - goto cleanup; - } - - main_menu(hnd, mem_ctx, sod.out.dom_hnd); - -cleanup: - - if(sod.out.dom_hnd) - cac_SamClose(hnd, mem_ctx, sod.out.dom_hnd); - - if(sod.out.sam) - cac_SamClose(hnd, mem_ctx, sod.out.sam); - - cac_FreeHandle(hnd); - - talloc_destroy(mem_ctx); - - return 0; -} diff --git a/examples/libmsrpc/cacusermgr/cacusermgr.h b/examples/libmsrpc/cacusermgr/cacusermgr.h deleted file mode 100644 index 01dbb60acf..0000000000 --- a/examples/libmsrpc/cacusermgr/cacusermgr.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Unix SMB/CIFS implementation. - * cacusermgr definitions and includes. - * - * Copyright (C) Chris Nicholls 2005 - * - * 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. */ - -#ifndef CACUSERMGR_H_ -#define CACUSERMGR_H_ - -#include "libmsrpc.h" -#include "includes.h" - -/*used for the simple pager - mgr_page()*/ -#define DEFAULT_SCREEN_LINES 20 - -/************** - * prototypes * - **************/ - -/*util.c*/ -void usage(); -int process_cmd_line(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, int argc, char **argv); -void mgr_getline(fstring line); -void mgr_page(uint32 line_count); -uint32 rid_or_name(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *dom_hnd, uint32 *rid, char **name); -char *get_new_password(TALLOC_CTX *mem_ctx); -void printerr(const char *msg, NTSTATUS status); -void print_rid_list(uint32 *rids, char **names, uint32 num_rids); -void print_lookup_records(CacLookupRidsRecord *map, uint32 num_rids); -int list_groups(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *dom_hnd); -void list_privs(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, CacUserInfo *info); -void add_privs(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, CacUserInfo *info); -void list_users(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *dom_hnd); - -void mgr_GetAuthDataFn(const char * pServer, - const char * pShare, - char * pWorkgroup, - int maxLenWorkgroup, - char * pUsername, - int maxLenUsername, - char * pPassword, - int maxLenPassword); - - -/*mgr_group.c*/ -void group_menu(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *dom_hnd, POLICY_HND *group_hnd); - -/*mgr_user.c*/ -void user_menu(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *dom_hnd, POLICY_HND *user_hnd); - -#endif /*CACUSERMGR_H_*/ diff --git a/examples/libmsrpc/cacusermgr/mgr_group.c b/examples/libmsrpc/cacusermgr/mgr_group.c deleted file mode 100644 index a936433e60..0000000000 --- a/examples/libmsrpc/cacusermgr/mgr_group.c +++ /dev/null @@ -1,210 +0,0 @@ -/* - * Unix SMB/CIFS implementation. - * cacusermgr group implementation. - * - * Copyright (C) Chris Nicholls 2005 - * - * 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. */ - -#include "cacusermgr.h" - -CacGroupInfo *get_group_info(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *group_hnd) { - struct SamGetGroupInfo getinfo; - - if(!hnd || !mem_ctx ||!group_hnd) - return NULL; - - ZERO_STRUCT(getinfo); - getinfo.in.group_hnd = group_hnd; - - if(!cac_SamGetGroupInfo(hnd, mem_ctx, &getinfo)) - printerr("Could not get group info.", hnd->status); - - return getinfo.out.info; -} - -void print_group_info(CacGroupInfo *info) { - if(!info) - return; - - printf(" Group Name : %s\n", info->name); - printf(" Description : %s\n", info->description); - printf(" Number of Members : %d\n", info->num_members); -} - -CacGroupInfo *modify_group_info(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *group_hnd) { - struct SamSetGroupInfo setinfo; - CacGroupInfo *info = NULL; - fstring tmp; - - info = get_group_info(hnd, mem_ctx, group_hnd); - - if(!info) - return NULL; - - printf("Description [%s]: ", info->description); - mgr_getline(tmp); - if(tmp[0] != '\0') - info->description = talloc_strdup(mem_ctx, tmp); - - ZERO_STRUCT(setinfo); - setinfo.in.group_hnd = group_hnd; - setinfo.in.info = info; - - if(!cac_SamSetGroupInfo(hnd, mem_ctx, &setinfo)) { - printerr("Could not set info.", hnd->status); - info = NULL; - } - - return info; -} - -void group_menu(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *dom_hnd, POLICY_HND *group_hnd) { - CacGroupInfo *info = NULL; - int rid_type = 0; - - fstring in; - - char *buf; - - struct SamGetGroupMembers getmem; - struct SamGetNamesFromRids getnames; - struct SamAddGroupMember add; - struct SamRemoveGroupMember del; - - info = get_group_info(hnd, mem_ctx, group_hnd); - - printf("\n"); - print_group_info(info); - - while(in[0] != 'b' && in[0] != 'B' && in[0] != 'q' && in[0] != 'Q') { - printf("\n"); - printf("[m] List Group Members\n"); - printf("[a] Add User To Group\n"); - printf("[r] Remove User From Group\n"); - printf("[l] List Users\n"); - printf("[v] View Group Info\n"); - printf("[d] Set Group Description\n"); - printf("[x] Delete Group\n"); - printf("[b] Back\n\n"); - - printf("Command: "); - mgr_getline(in); - - printf("\n"); - - switch(in[0]) { - case 'a': /*add member to group*/ - case 'A': - ZERO_STRUCT(add); - add.in.group_hnd = group_hnd; - - printf("Enter RID or Name: "); - rid_type = rid_or_name(hnd, mem_ctx, dom_hnd, &add.in.rid, &buf); - - if(rid_type != CAC_USER_RID) { - printf("Invalid User.\n"); - break; - } - - if(!cac_SamAddGroupMember(hnd, mem_ctx, &add)) { - printerr("Could not add user to group.", hnd->status); - } - break; - - case 'r': /*remove user from group*/ - case 'R': - ZERO_STRUCT(del); - del.in.group_hnd = group_hnd; - - printf("Enter RID or Name: "); - rid_type = rid_or_name(hnd, mem_ctx, dom_hnd, &del.in.rid, &buf); - - if(rid_type != CAC_USER_RID) { - printf("Invalid User.\n"); - break; - } - - if(!cac_SamRemoveGroupMember(hnd, mem_ctx, &del)) { - printerr("Could not remove use from group.", hnd->status); - } - break; - - case 'l': /*list users*/ - case 'L': - list_users(hnd, mem_ctx, dom_hnd); - break; - - case 'm': /*list members*/ - case 'M': - ZERO_STRUCT(getmem); - getmem.in.group_hnd = group_hnd; - - if(!cac_SamGetGroupMembers(hnd, mem_ctx, &getmem)) { - printerr("Could not get members.", hnd->status); - break; - } - - ZERO_STRUCT(getnames); - getnames.in.dom_hnd = dom_hnd; - getnames.in.rids = getmem.out.rids; - getnames.in.num_rids = getmem.out.num_members; - - if(!cac_SamGetNamesFromRids(hnd, mem_ctx, &getnames)) { - printerr("Could not lookup names.", hnd->status); - break; - } - - printf("Group has %d members:\n", getnames.out.num_names); - print_lookup_records(getnames.out.map, getnames.out.num_names); - - break; - - case 'd': /*set description*/ - case 'D': - info = modify_group_info(hnd, mem_ctx, group_hnd); - - if(info) - printf("Set Group Info.\n"); - break; - - case 'v': /*view info*/ - case 'V': - info = get_group_info(hnd, mem_ctx, group_hnd); - print_group_info(info); - break; - - case 'x': /*delete group*/ - case 'X': - if(!cac_SamDeleteGroup(hnd, mem_ctx, group_hnd)) - printerr("Could Not Delete Group.", hnd->status); - - /*we want to go back to the main menu*/ - in[0] = 'b'; - break; - - case 'b': /*back*/ - case 'B': - case 'q': - case 'Q': - break; - - default: - printf("Invalid Command.\n"); - } - } - - cac_SamClose(hnd, mem_ctx, group_hnd); -} diff --git a/examples/libmsrpc/cacusermgr/mgr_user.c b/examples/libmsrpc/cacusermgr/mgr_user.c deleted file mode 100644 index 7e2e56499f..0000000000 --- a/examples/libmsrpc/cacusermgr/mgr_user.c +++ /dev/null @@ -1,416 +0,0 @@ -/* - * Unix SMB/CIFS implementation. - * cacusermgr user implementation. - * - * Copyright (C) Chris Nicholls 2005 - * - * 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. */ - -#include "cacusermgr.h" - -void print_user_info(CacUserInfo *info) { - printf("\n"); - printf(" User Name : %s\n", info->username); - printf(" Full Name : %s\n", info->full_name); - printf(" Home Dir : %s\n", info->home_dir); - printf(" Home Drive : %s\n", info->home_drive); - printf(" Profile Path : %s\n", info->profile_path); - printf(" Logon Script : %s\n", info->logon_script); - printf(" Description : %s\n", info->description); - printf(" Workstations : %s\n", info->workstations); - printf(" Remote Dial : %s\n", info->dial); - - printf(" Logon Time : %s\n", http_timestring(info->logon_time)); - printf(" Logoff Time : %s\n", http_timestring(info->logoff_time)); - printf(" Kickoff Time : %s\n", http_timestring(info->kickoff_time)); - printf(" Pass last set : %s\n", http_timestring(info->pass_last_set_time)); - printf(" Pass can set : %s\n", http_timestring(info->pass_can_change_time)); - printf(" Pass must set : %s\n", http_timestring(info->pass_must_change_time)); - - printf(" User RID : 0x%x\n", info->rid); - printf(" Group RID : 0x%x\n", info->group_rid); - printf(" User Type : "); - - if(info->acb_mask & ACB_NORMAL) - printf("Normal User\n"); - else if(info->acb_mask & ACB_TEMPDUP) - printf("Temporary Duplicate Account\n"); - else if(info->acb_mask & ACB_DOMTRUST) - printf("Inter-Domain Trust Account\n"); - else if(info->acb_mask & ACB_WSTRUST) - printf("Workstation Trust Account\n"); - else if(info->acb_mask & ACB_SVRTRUST) - printf("Server Trust Account\n"); - else - printf("\n"); - - printf(" Disabled : %s\n", (info->acb_mask & ACB_DISABLED) ? "Yes" : "No"); - printf(" Locked : %s\n", (info->acb_mask & ACB_AUTOLOCK) ? "Yes" : "No"); - printf(" Pass Expires : %s\n", (info->acb_mask & ACB_PWNOEXP) ? "No" : "Yes"); - printf(" Pass Required : %s\n", (info->acb_mask & ACB_PWNOTREQ) ? "No" : "Yes"); - -} - -CacUserInfo *modify_user_info(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *user_hnd) { - CacUserInfo *info = NULL; - fstring tmp; - - struct SamGetUserInfo getinfo; - struct SamSetUserInfo setinfo; - - ZERO_STRUCT(getinfo); - ZERO_STRUCT(setinfo); - - getinfo.in.user_hnd = user_hnd; - - if(!cac_SamGetUserInfo(hnd, mem_ctx, &getinfo)) { - printerr("Could not get user info.", hnd->status); - return NULL; - } - - info = getinfo.out.info; - - printf("\n"); - printf(" User Name [%s]: ", info->username); - mgr_getline(tmp); - if(tmp[0] != '\0') - info->username = talloc_strdup(mem_ctx, tmp); - - printf(" Full Name [%s]: ", info->full_name); - mgr_getline(tmp); - if(tmp[0] != '\0') - info->full_name = talloc_strdup(mem_ctx, tmp); - - printf(" Description [%s]: ", info->description); - mgr_getline(tmp); - if(tmp[0] != '\0') - info->description = talloc_strdup(mem_ctx, tmp); - - printf(" Home Dir [%s]: ", info->home_dir); - mgr_getline(tmp); - if(tmp[0] != '\0') - info->home_dir = talloc_strdup(mem_ctx, tmp); - - printf(" Home Drive [%s]: ", info->home_drive); - mgr_getline(tmp); - if(tmp[0] != '\0') - info->home_drive = talloc_strdup(mem_ctx, tmp); - - printf(" Profile Path [%s]: ", info->profile_path); - mgr_getline(tmp); - if(tmp[0] != '\0') - info->profile_path = talloc_strdup(mem_ctx, tmp); - - printf(" Logon Script [%s]: ", info->logon_script); - mgr_getline(tmp); - if(tmp[0] != '\0') - info->logon_script = talloc_strdup(mem_ctx, tmp); - - printf(" Workstations [%s]: ", info->workstations); - mgr_getline(tmp); - if(tmp[0] != '\0') - info->workstations = talloc_strdup(mem_ctx, tmp); - - printf(" Remote Dial [%s]: ", info->dial); - mgr_getline(tmp); - if(tmp[0] != '\0') - info->dial = talloc_strdup(mem_ctx, tmp); - - printf(" Disabled [%s] (y/n): ", (info->acb_mask & ACB_DISABLED) ? "Yes" : "No"); - mgr_getline(tmp); - if(tmp[0] == 'y' || tmp[0] == 'Y') - info->acb_mask |= ACB_DISABLED; - else if(tmp[0] == 'n' || tmp[0] == 'N') - info->acb_mask ^= (info->acb_mask & ACB_DISABLED) ? ACB_DISABLED : 0x0; - - printf(" Pass Expires [%s] (y/n): ", (info->acb_mask & ACB_PWNOEXP) ? "No" : "Yes"); - mgr_getline(tmp); - if(tmp[0] == 'n' || tmp[0] == 'N') - info->acb_mask |= ACB_PWNOEXP; - else if(tmp[0] == 'y' || tmp[0] == 'Y') - info->acb_mask ^= (info->acb_mask & ACB_PWNOEXP) ? ACB_PWNOEXP : 0x0; - - printf(" Pass Required [%s] (y/n): ", (info->acb_mask & ACB_PWNOTREQ) ? "No" : "Yes"); - mgr_getline(tmp); - if(tmp[0] == 'n' || tmp[0] == 'N') - info->acb_mask |= ACB_PWNOTREQ; - else if(tmp[0] == 'y' || tmp[0] == 'Y') - info->acb_mask ^= (info->acb_mask & ACB_PWNOTREQ) ? ACB_PWNOTREQ : 0x0; - - setinfo.in.user_hnd = user_hnd; - setinfo.in.info = info; - - if(!cac_SamSetUserInfo(hnd, mem_ctx, &setinfo)) { - printerr("Could not set user info.", hnd->status); - } - - return info; -} - -void add_user_to_group(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, CacUserInfo *info, POLICY_HND *dom_hnd) { - int rid_type = 0; - - char *tmp = NULL; - - struct SamOpenGroup og; - struct SamAddGroupMember add; - - ZERO_STRUCT(og); - ZERO_STRUCT(add); - - printf("Group RID or Name:"); - - og.in.dom_hnd = dom_hnd; - og.in.access = MAXIMUM_ALLOWED_ACCESS; - rid_type = rid_or_name(hnd, mem_ctx, dom_hnd, &og.in.rid, &tmp); - - if(!cac_SamOpenGroup(hnd, mem_ctx, &og)) { - printerr("Could not open group.", hnd->status); - return; - } - - add.in.group_hnd = og.out.group_hnd; - add.in.rid = info->rid; - - if(!cac_SamAddGroupMember(hnd, mem_ctx, &add)) { - printerr("Could not add user to group.", hnd->status); - } - - cac_SamClose(hnd, mem_ctx, og.out.group_hnd); -} - -void remove_user_from_group(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, CacUserInfo *info, POLICY_HND *dom_hnd) { - int rid_type = 0; - - char *tmp = NULL; - - struct SamOpenGroup og; - struct SamRemoveGroupMember del; - - ZERO_STRUCT(og); - ZERO_STRUCT(del); - - printf("Group RID or Name:"); - - og.in.dom_hnd = dom_hnd; - og.in.access = MAXIMUM_ALLOWED_ACCESS; - rid_type = rid_or_name(hnd, mem_ctx, dom_hnd, &og.in.rid, &tmp); - - if(!cac_SamOpenGroup(hnd, mem_ctx, &og)) { - printerr("Could not open group.", hnd->status); - return; - } - - del.in.group_hnd = og.out.group_hnd; - del.in.rid = info->rid; - - if(!cac_SamRemoveGroupMember(hnd, mem_ctx, &del)) { - printerr("Could not add user to group.", hnd->status); - } - - cac_SamClose(hnd, mem_ctx, og.out.group_hnd); -} - -void user_menu(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *dom_hnd, POLICY_HND *user_hnd) { - fstring in; - - struct SamGetUserInfo getinfo; - struct SamSetPassword setpass; - struct SamGetGroupsForUser groups; - struct SamGetNamesFromRids gnfr; - - CacUserInfo *info = NULL; - - if(!hnd || !mem_ctx || !user_hnd) { - printf("Must open user.\n"); - return; - } - - /*get the userinfo and print it out*/ - ZERO_STRUCT(getinfo); - getinfo.in.user_hnd = user_hnd; - - if(!cac_SamGetUserInfo(hnd, mem_ctx, &getinfo)) { - printerr("Could not get info.", hnd->status); - info = NULL; - } - else { - info = getinfo.out.info; - print_user_info(info); - } - - /*now deal with the menu*/ - in[0] = '\0'; - while(in[0] != 'b' && in[0] != 'B' && in[0] != 'q' && in[0] != 'Q') { - printf("\n"); - printf("[s] Set Password\n"); - - if(info && (info->acb_mask & ACB_DISABLED)) - printf("[e] Enable User\n"); - else if(info) - printf("[d] Disable User\n"); - - printf("[v] View User Info\n"); - printf("[m] Modify User Info\n"); - printf("[x] Delete User\n\n"); - - printf("[g] List Group Membership\n"); - printf("[a] Add User To Group\n"); - printf("[l] List Domain Groups\n"); - printf("[r] Remove User From Group\n\n"); - - printf("[b] Back\n\n"); - - printf("Command: "); - mgr_getline(in); - - printf("\n"); - - switch(in[0]) { - case 'g': /*list group membership*/ - case 'G': - ZERO_STRUCT(groups); - groups.in.user_hnd = user_hnd; - - if(!cac_SamGetGroupsForUser(hnd, mem_ctx, &groups)) { - printerr("Could not get groups.", hnd->status); - break; - } - - ZERO_STRUCT(gnfr); - gnfr.in.dom_hnd = dom_hnd; - gnfr.in.rids = groups.out.rids; - gnfr.in.num_rids = groups.out.num_groups; - - if(!cac_SamGetNamesFromRids(hnd, mem_ctx, &gnfr)) { - printerr("Could not map RIDs to names.", hnd->status); - break; - } - - print_lookup_records(gnfr.out.map, gnfr.out.num_names); - - break; - case 's': /*reset password*/ - case 'S': - ZERO_STRUCT(setpass); - setpass.in.user_hnd = user_hnd; - setpass.in.password = get_new_password(mem_ctx); - - if(!setpass.in.password) { - printf("Out of memory.\n"); - break; - } - - if(!cac_SamSetPassword(hnd, mem_ctx, &setpass)) { - printerr("Could not set password.", hnd->status); - } - else { - printf("Reset password.\n"); - } - break; - - case 'e': /*enable user*/ - case 'E': - if(info && !(info->acb_mask & ACB_DISABLED)) - break; - - if(!cac_SamEnableUser(hnd, mem_ctx, user_hnd)) { - printerr("Could not enable user.", hnd->status); - } - else { - printf("Enabled User.\n"); - /*toggle the disabled ACB bit in our local copy of the info*/ - info->acb_mask ^= ACB_DISABLED; - } - break; - - case 'd': /*disable user*/ - case 'D': - if(info && (info->acb_mask & ACB_DISABLED)) - break; - - if(!cac_SamDisableUser(hnd, mem_ctx, user_hnd)) { - printerr("Could not disable user.", hnd->status); - } - else { - printf("Disabled User.\n"); - /*toggle the disabled ACB bit in our local copy of the info*/ - info->acb_mask ^= ACB_DISABLED; - } - break; - - case 'v': /*view user info*/ - case 'V': - ZERO_STRUCT(getinfo); - getinfo.in.user_hnd = user_hnd; - - if(!cac_SamGetUserInfo(hnd, mem_ctx, &getinfo)) { - printerr("Could not get info.", hnd->status); - info = NULL; - } - else { - info = getinfo.out.info; - print_user_info(info); - } - - break; - - case 'm': /*modify user info*/ - case 'M': - info = modify_user_info(hnd, mem_ctx, user_hnd); - - if(info) - printf("Updated user info.\n"); - break; - - case 'l': /*list domain groups*/ - case 'L': - list_groups(hnd, mem_ctx, dom_hnd); - break; - - case 'a': /*add user to group*/ - case 'A': - add_user_to_group(hnd, mem_ctx, info, dom_hnd); - break; - - case 'r': /*remove user from group*/ - case 'R': - remove_user_from_group(hnd, mem_ctx, info, dom_hnd); - break; - - case 'x': /*delete user*/ - case 'X': - if(!cac_SamDeleteUser(hnd, mem_ctx, user_hnd)) - printerr("Could not delete user.", hnd->status); - - /*we want to go back to the main menu*/ - in[0] = 'b'; - break; - - case 'b': /*back*/ - case 'B': - case 'q': - case 'Q': - /*do nothing*/ - break; - - default: - printf("Invalid command.\n"); - } - } - - /*close the user before returning*/ - cac_SamClose(hnd, mem_ctx, user_hnd); -} diff --git a/examples/libmsrpc/cacusermgr/util.c b/examples/libmsrpc/cacusermgr/util.c deleted file mode 100644 index 1629911812..0000000000 --- a/examples/libmsrpc/cacusermgr/util.c +++ /dev/null @@ -1,343 +0,0 @@ -/* - * Unix SMB/CIFS implementation. - * cacusermgr utility functions. - * - * Copyright (C) Chris Nicholls 2005 - * - * 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. */ - -#include "cacusermgr.h" - -/*prints usage and quits*/ -void usage() { - printf("Usage:\n"); - printf(" cacusermgr [options] server\n\n"); - printf("options:\n"); - printf(" -u USERNAME Username to login with\n"); - printf(" -d/-w DOMAIN Domain name\n"); - printf(" -D LEVEL Debug level\n"); - printf(" -h Print this message\n"); - - exit(1); -} - -/*initializes values in the server handle from the command line returns 0 if there is a problem, non-zero if everything is ok*/ -int process_cmd_line(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, int argc, char **argv) { - char op; - - if(!hnd || !mem_ctx || !argc) - return 0; - - while( (op = getopt(argc, argv, "u:U:d:w:W:D:h")) != -1) { - switch(op) { - case 'u': /*username*/ - case 'U': - if(optarg) - strncpy(hnd->username, optarg, sizeof(fstring)); - else - usage(); - break; - - case 'd': /*domain name*/ - case 'w': - case 'W': - if(optarg) - strncpy(hnd->domain, optarg, sizeof(fstring)); - else - usage(); - break; - - case 'D': /*debug level*/ - if(optarg) - hnd->debug = atoi(optarg); - else - usage(); - break; - - case 'h': /*help*/ - usage(); - break; - - case '?': - default: - printf("Unknown option -%c\n", op); - usage(); - } - } - - if(optind >= argc) - usage(); - - /*whatever is less should be the server*/ - strncpy(hnd->server, argv[optind], sizeof(fstring)); - - return 1; -} - -void mgr_getline(fstring line) { - - fgets(line, sizeof(fstring), stdin); - - if(line[strlen(line) - 1] == '\n') - line[strlen(line) - 1] = '\0'; - -} - -/*this is pretty similar to the other get_auth_data_fn's*/ -void mgr_GetAuthDataFn(const char * pServer, - const char * pShare, - char * pWorkgroup, - int maxLenWorkgroup, - char * pUsername, - int maxLenUsername, - char * pPassword, - int maxLenPassword) - -{ - char temp[sizeof(fstring)]; - - static char authUsername[sizeof(fstring)]; - static char authWorkgroup[sizeof(fstring)]; - static char authPassword[sizeof(fstring)]; - static char authSet = 0; - - char *pass = NULL; - - if (authSet) - { - strncpy(pWorkgroup, authWorkgroup, maxLenWorkgroup - 1); - strncpy(pUsername, authUsername, maxLenUsername - 1); - strncpy(pPassword, authPassword, maxLenPassword - 1); - } - else - { - if(pWorkgroup[0] != '\0') { - strncpy(authWorkgroup, pWorkgroup, maxLenWorkgroup - 1); - } - else { - d_printf("Domain: [%s] ", pWorkgroup); - mgr_getline(pWorkgroup); - - if (temp[0] != '\0') - { - strncpy(pWorkgroup, temp, maxLenWorkgroup - 1); - strncpy(authWorkgroup, temp, maxLenWorkgroup - 1); - } - } - - - if(pUsername[0] != '\0') { - strncpy(authUsername, pUsername, maxLenUsername - 1); - } - else { - d_printf("Username: [%s] ", pUsername); - mgr_getline(pUsername); - - if (temp[strlen(temp) - 1] == '\n') /* A new line? */ - { - temp[strlen(temp) - 1] = '\0'; - } - - if (temp[0] != '\0') - { - strncpy(pUsername, temp, maxLenUsername - 1); - strncpy(authUsername, pUsername, maxLenUsername - 1); - } - } - if(pPassword[0] != '\0') { - strncpy(authPassword, pPassword, maxLenPassword - 1); - } - else { - pass = getpass("Password: "); - if (pass) - fstrcpy(temp, pass); - if (temp[strlen(temp) - 1] == '\n') /* A new line? */ - { - temp[strlen(temp) - 1] = '\0'; - } - if (temp[0] != '\0') - { - strncpy(pPassword, temp, maxLenPassword - 1); - strncpy(authPassword, pPassword, maxLenPassword - 1); - } - } - authSet = 1; - } -} - -void mgr_page(uint32 line_count) { - - if( (line_count % DEFAULT_SCREEN_LINES) != 0) - return; - - printf("--Press enter to continue--\n"); - getchar(); -} - -/*reads a line from stdin, figures out if it is a RID or name, gets a CacLookupRidsRecord and then returns the type*/ -uint32 rid_or_name(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *dom_hnd, uint32 *rid, char **name) { - fstring line; - - BOOL is_rid = False; - uint32 rid_type = 0; - - struct SamGetNamesFromRids getnames; - struct SamGetRidsFromNames getrids; - - mgr_getline(line); - - if(strncmp(line, "0x", 2) == 0) { - /*then this is a RID*/ - sscanf( (line + 2), "%x", rid); - is_rid = True; - } - else { - /*then this is a name*/ - *name = talloc_strdup(mem_ctx, line); - } - - if(is_rid) { - ZERO_STRUCT(getnames); - - getnames.in.dom_hnd = dom_hnd; - getnames.in.rids = rid; - getnames.in.num_rids = 1; - - cac_SamGetNamesFromRids(hnd, mem_ctx, &getnames); - - if(getnames.out.num_names > 0) - rid_type = getnames.out.map[0].type; - - } - else { - ZERO_STRUCT(getrids); - - getrids.in.dom_hnd = dom_hnd; - getrids.in.names = name; - getrids.in.num_names = 1; - - cac_SamGetRidsFromNames(hnd, mem_ctx, &getrids); - - if(getrids.out.num_rids > 0) { - rid_type = getrids.out.map[0].type; - - /*send back the RID so cac_SamOpenXX() doesn't have to look it up*/ - *rid = getrids.out.map[0].rid; - } - } - - return rid_type; -} - -/*print's out some common error messages*/ -void printerr(const char *msg, NTSTATUS status) { - if(NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED)) - printf("%s You do not have sufficient rights.\n", msg); - - else if(NT_STATUS_EQUAL(status, NT_STATUS_NO_SUCH_USER)) - printf("%s No such user.\n", msg); - - else if(NT_STATUS_EQUAL(status, NT_STATUS_NO_SUCH_GROUP)) - printf("%s No such group.\n", msg); - - else if(NT_STATUS_EQUAL(status, NT_STATUS_USER_EXISTS)) - printf("%s User already exists.\n", msg); - - else if(NT_STATUS_EQUAL(status, NT_STATUS_GROUP_EXISTS)) - printf("%s Group already exists.\n", msg); - - else - printf("%s %s.\n", msg, nt_errstr(status)); -} - -char *get_new_password(TALLOC_CTX *mem_ctx) { - char *pass1 = NULL; - - pass1 = getpass("Enter new password: "); - - return talloc_strdup(mem_ctx, pass1); -} - -void print_rid_list(uint32 *rids, char **names, uint32 num_rids) { - uint32 i = 0; - - if(!names || !rids) - return; - - printf(" RID Name\n"); - - while(i < num_rids) { - printf("[0x%x] [%s]\n", rids[i], names[i]); - - i++; - - mgr_page(i); - } -} - -void print_lookup_records(CacLookupRidsRecord *map, uint32 num_rids) { - uint32 i = 0; - - if(!map) - return; - - printf("RID Name\n"); - - while(i < num_rids) { - if(map[i].found) { - printf("[0x%x] [%s]\n", map[i].rid, map[i].name); - } - - i++; - - mgr_page(i); - } -} - -int list_groups(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *dom_hnd) { - struct SamEnumGroups eg; - - if(!hnd || !mem_ctx || !dom_hnd) - return 0; - - ZERO_STRUCT(eg); - eg.in.dom_hnd = dom_hnd; - - while(cac_SamEnumGroups(hnd, mem_ctx, &eg)) - print_rid_list(eg.out.rids, eg.out.names, eg.out.num_groups); - - if(CAC_OP_FAILED(hnd->status)) { - printerr("Could not enumerate groups.", hnd->status); - return 0; - } - - return 1; -} - -void list_users(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *dom_hnd) { - struct SamEnumUsers eu; - - if(!hnd || !mem_ctx || !dom_hnd) - return; - - ZERO_STRUCT(eu); - eu.in.dom_hnd = dom_hnd; - - while(cac_SamEnumUsers(hnd, mem_ctx, &eu)) - print_rid_list(eu.out.rids, eu.out.names, eu.out.num_users); - - if(CAC_OP_FAILED(hnd->status)) - printerr("Could not enumerate users.", hnd->status); -} diff --git a/examples/libmsrpc/test/Makefile b/examples/libmsrpc/test/Makefile deleted file mode 100644 index 95fa5effa5..0000000000 --- a/examples/libmsrpc/test/Makefile +++ /dev/null @@ -1,99 +0,0 @@ -CC=gcc -INCLUDES= -I`pwd` -I../../../source/ -I../../../source/include -I../../../source/ubiqx - -DEFS= -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -#CFLAGS= -O -D_SAMBA_BUILD_ -gstabs -Wall -Wshadow -Wstrict-prototypes -Wpointer-arith -Wcast-align -Wwrite-strings -DDEBUG_PASSWORD -DDEVELOPER -Wdeclaration-after-statement -g $(INCLUDES) $(DEFS) -fPIC - -CFLAGS= -g -Wall -ansi $(INCLUDES) - -LDFLAGS=-L. -L../../bin/ -LIBS=../../../source/bin/libmsrpc.so - -TESTS= lsapol lsaq lsaenum lsaenumprivs lsapriv ear \ - regkey regopenkey regkeyenum regvalenum regsetval regqueryval regdelete security \ - adduser samenum samlookup samgroup enable disable dominfo samuser \ - svc \ - smbc - -all: $(TESTS) - -lsapol: lsa/lsapol.o - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) - -lsapriv: lsa/lsapriv.o test_util.o - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< test_util.o $(LIBS) - -lsaq: lsa/lsaq.o - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) - -lsaenum: lsa/lsaenum.o - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) - -lsaenumprivs: lsa/lsaenumprivs.o - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) - -lsaaddrights: lsa/lsaaddrights.o - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) - -ear: lsa/ear.o - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) - -regkey: reg/regkey.o - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) - -regopenkey: reg/regopenkey.o - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) - -regkeyenum: reg/regkeyenum.o - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) - -regkeycreate: reg/regkeycreate.o - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) - -regvalenum: reg/regvalenum.o test_util.o - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< test_util.o $(LIBS) - -regsetval: reg/regsetval.o test_util.o - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< test_util.o $(LIBS) - -regqueryval: reg/regqueryval.o test_util.o - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< test_util.o $(LIBS) - -regdelete: reg/regdelete.o test_util.o - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< test_util.o $(LIBS) - -security: reg/security.o test_util.o - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< test_util.o $(LIBS) - -adduser: sam/adduser.o test_util.o - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< test_util.o $(LIBS) - -samenum: sam/samenum.o test_util.o - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< test_util.o $(LIBS) - -samlookup: sam/samlookup.o test_util.o - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< test_util.o $(LIBS) - -samgroup: sam/samgroup.o test_util.o - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< test_util.o $(LIBS) - -enable: sam/enable.o test_util.o - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< test_util.o $(LIBS) - -disable: sam/disable.o test_util.o - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< test_util.o $(LIBS) - -samuser: sam/samuser.o test_util.o - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< test_util.o $(LIBS) - -dominfo: sam/dominfo.o test_util.o - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< test_util.o $(LIBS) - -svc: svcctl/svc.o test_util.o - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< test_util.o $(LIBS) - -smbc: smbc_test/smbc.o test_util.o - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< test_util.o $(LIBS) ../../../source/bin/libsmbclient.so - -clean: - rm -f $(TESTS) *.o lsa/*.o reg/*.o sam/*.o diff --git a/examples/libmsrpc/test/README b/examples/libmsrpc/test/README deleted file mode 100644 index 9352905b5b..0000000000 --- a/examples/libmsrpc/test/README +++ /dev/null @@ -1,8 +0,0 @@ -This code was written to test the different library functions. However, a simple example of almost every libmsrpc call can be found -in this code. - -notes: most of the programs use a modified smbc_get_auth_data_fn which will not prompt for a user/domain/password so expect flaky results -if you run the tests with just a server, ie: svc remote_machine - - -If you get errors about the libmsrpc.so object, make sure your LD_LIBRARY_PATH points to /path/to/samba3/source/bin diff --git a/examples/libmsrpc/test/lsa/ear.c b/examples/libmsrpc/test/lsa/ear.c deleted file mode 100644 index 8a8202543d..0000000000 --- a/examples/libmsrpc/test/lsa/ear.c +++ /dev/null @@ -1,261 +0,0 @@ -/* connects to an LSA, asks for a list of server names, prints out their sids, then looks up their names from the sids and prints them out again - * if you run as lsaq -p, then it will simulate a partial success for cac_GetNamesFromSids. It will try to lookup the server's local and domain sids - */ - - -#include "libmsrpc.h" -#include "includes.h" - -void fill_conn_info(CacServerHandle *hnd) { - pstring domain; - pstring username; - pstring password; - pstring server; - - fprintf(stdout, "Enter domain name: "); - fscanf(stdin, "%s", domain); - - fprintf(stdout, "Enter username: "); - fscanf(stdin, "%s", username); - - fprintf(stdout, "Enter password (no input masking): "); - fscanf(stdin, "%s", password); - - fprintf(stdout, "Enter server (ip or name): "); - fscanf(stdin, "%s", server); - - hnd->domain = SMB_STRDUP(domain); - hnd->username = SMB_STRDUP(username); - hnd->password = SMB_STRDUP(password); - hnd->server = SMB_STRDUP(server); -} - -void get_server_names(TALLOC_CTX *mem_ctx, int *num_names, char ***names) { - int i = 0; - pstring tmp; - - fprintf(stdout, "How many names do you want to lookup?: "); - fscanf(stdin, "%d", num_names); - - *names = TALLOC_ARRAY(mem_ctx, char *, *num_names); - if(*names == NULL) { - fprintf(stderr, "No memory for allocation\n"); - exit(-1); - } - - for(i = 0; i < *num_names; i++) { - fprintf(stdout, "Enter name: "); - fscanf(stdin, "%s", tmp); - (*names)[i] = talloc_strdup(mem_ctx, tmp); - } -} - -int main(int argc, char **argv) { - int i; - int result; - char **names; - int num_names; - int num_sids; - CacServerHandle *hnd = NULL; - POLICY_HND *lsa_pol = NULL; - TALLOC_CTX *mem_ctx = NULL; - - DOM_SID *sid_buf = NULL; - - BOOL sim_partial = False; - - if(argc > 1 && strcmp(argv[1], "-p") == 0) - sim_partial = True; - - mem_ctx = talloc_init("lsaq"); - - hnd = cac_NewServerHandle(False); - - fill_conn_info(hnd); - - get_server_names(mem_ctx, &num_names, &names); - - /*connect to the PDC and open a LSA handle*/ - if(!cac_Connect(hnd, NULL)) { - fprintf(stderr, "Could not connect to server.\n Error %s.\n", nt_errstr(hnd->status)); - cac_FreeHandle(hnd); - exit(-1); - } - - fprintf(stdout, "Connected to server: %s\n", hnd->server); - - struct LsaOpenPolicy lop; - ZERO_STRUCT(lop); - - lop.in.access = SEC_RIGHT_MAXIMUM_ALLOWED; - lop.in.security_qos = True; - - if(!cac_LsaOpenPolicy(hnd, mem_ctx, &lop)) { - fprintf(stderr, "Could not get lsa policy handle.\n Error: %s\n", nt_errstr(hnd->status)); - cac_FreeHandle(hnd); - exit(-1); - } - - fprintf(stdout, "Opened Policy Handle\n"); - - /*just to make things neater*/ - lsa_pol = lop.out.pol; - - /*fetch the local sid and domain sid for the pdc*/ - - struct LsaFetchSid fsop; - ZERO_STRUCT(fsop); - - fsop.in.pol = lsa_pol; - fsop.in.info_class = (CAC_LOCAL_INFO|CAC_DOMAIN_INFO); - - fprintf(stdout, "fetching SID info for %s\n", hnd->server); - - result = cac_LsaFetchSid(hnd, mem_ctx, &fsop); - if(!result) { - fprintf(stderr, "Could not get sid for server: %s\n. Error: %s\n", hnd->server, nt_errstr(hnd->status)); - cac_FreeHandle(hnd); - talloc_destroy(mem_ctx); - exit(-1); - } - - if(result == CAC_PARTIAL_SUCCESS) { - fprintf(stdout, "could not retrieve both domain and local information\n"); - } - - - fprintf(stdout, "Fetched SID info for %s\n", hnd->server); - if(fsop.out.local_sid != NULL) - fprintf(stdout, " domain: %s. Local SID: %s\n", fsop.out.local_sid->domain, sid_string_static(&fsop.out.local_sid->sid)); - - if(fsop.out.domain_sid != NULL) - fprintf(stdout, " domain: %s, Domain SID: %s\n", fsop.out.domain_sid->domain, sid_string_static(&fsop.out.domain_sid->sid)); - - fprintf(stdout, "Looking up sids\n"); - - - struct LsaGetSidsFromNames gsop; - ZERO_STRUCT(gsop); - - gsop.in.pol = lsa_pol; - gsop.in.num_names = num_names; - gsop.in.names = names; - - result = cac_LsaGetSidsFromNames(hnd, mem_ctx, &gsop); - - if(!result) { - fprintf(stderr, "Could not lookup any sids!\n Error: %s\n", nt_errstr(hnd->status)); - goto done; - } - - if(result == CAC_PARTIAL_SUCCESS) { - fprintf(stdout, "Not all names could be looked up.\nThe following names were not found:\n"); - - for(i = 0; i < (num_names - gsop.out.num_found); i++) { - fprintf(stdout, " %s\n", gsop.out.unknown[i]); - } - - fprintf(stdout, "\n"); - } - - /*buffer the sids so we can look them up back to names*/ - num_sids = (sim_partial) ? gsop.out.num_found + 2: gsop.out.num_found; - sid_buf = TALLOC_ARRAY(mem_ctx, DOM_SID, num_sids); - - fprintf(stdout, "%d names were resolved: \n", gsop.out.num_found); - - - i = 0; - while(i < gsop.out.num_found) { - fprintf(stdout, " Name: %s\n SID: %s\n\n", gsop.out.sids[i].name, sid_string_static(&gsop.out.sids[i].sid)); - - sid_buf[i] = gsop.out.sids[i].sid; - - printf("Attempting to open account\n"); - - struct LsaOpenAccount loa; - ZERO_STRUCT(loa); - - loa.in.pol = lsa_pol; - loa.in.access = SEC_RIGHT_MAXIMUM_ALLOWED; - loa.in.sid = &gsop.out.sids[i].sid; - - if(!cac_LsaOpenAccount(hnd, mem_ctx, &loa)) { - fprintf(stderr, "Could not open account.\n Error: %s\n", nt_errstr(hnd->status)); - } - - printf("\nEnumerating privs:"); - struct LsaEnumAccountRights earop; - ZERO_STRUCT(earop); - - earop.in.pol = lsa_pol; - - earop.in.sid = &gsop.out.sids[i].sid; - - if(!cac_LsaEnumAccountRights(hnd, mem_ctx, &earop)) { - fprintf(stderr, "Could not enumerate account rights.\n Error: %s\n", nt_errstr(hnd->status)); - } - - int j; - printf( "Rights: "); - for(j = 0; j < earop.out.num_privs; j++) { - printf(" %s\n", earop.out.priv_names[j]); - } - - printf("\n"); - - - i++; - } - - /*if we want a partial success to occur below, then add the server's SIDs to the end of the array*/ - if(sim_partial) { - sid_buf[i] = fsop.out.local_sid->sid; - sid_buf[i+1] = fsop.out.domain_sid->sid; - } - - fprintf(stdout, "Looking up Names from SIDs\n"); - - struct LsaGetNamesFromSids gnop; - ZERO_STRUCT(gnop); - - gnop.in.pol = lsa_pol; - gnop.in.num_sids = num_sids; - gnop.in.sids = sid_buf; - - result = cac_LsaGetNamesFromSids(hnd, mem_ctx, &gnop); - - if(!result) { - fprintf(stderr, "Could not lookup any names!.\n Error: %s\n", nt_errstr(hnd->status)); - goto done; - } - - if(result == CAC_PARTIAL_SUCCESS) { - fprintf(stdout, "\nNot all SIDs could be looked up.\n. The following SIDs were not found:\n"); - - for(i = 0; i < (num_sids - gnop.out.num_found); i++) { - fprintf(stdout, "SID: %s\n", sid_string_static(&gnop.out.unknown[i])); - } - - fprintf(stdout, "\n"); - } - - fprintf(stdout, "%d SIDs were resolved: \n", gnop.out.num_found); - for(i = 0; i < gnop.out.num_found; i++) { - fprintf(stdout, " SID: %s\n Name: %s\n", sid_string_static(&gnop.out.sids[i].sid), gsop.out.sids[i].name); - } - -done: - - if(!cac_LsaClosePolicy(hnd, mem_ctx, lsa_pol)) { - fprintf(stderr, "Could not close LSA policy handle.\n Error: %s\n", nt_errstr(hnd->status)); - } - else { - fprintf(stdout, "Closed Policy handle.\n"); - } - - cac_FreeHandle(hnd); - talloc_destroy(mem_ctx); - - return 0; -} diff --git a/examples/libmsrpc/test/lsa/lsaenum.c b/examples/libmsrpc/test/lsa/lsaenum.c deleted file mode 100644 index d4ad4f73aa..0000000000 --- a/examples/libmsrpc/test/lsa/lsaenum.c +++ /dev/null @@ -1,96 +0,0 @@ -/*enumerates SIDs*/ - -#include "libmsrpc.h" -#include "includes.h" - -int main(int argc, char **argv) { - - CacServerHandle *hnd = NULL; - TALLOC_CTX *mem_ctx = NULL; - - POLICY_HND *pol = NULL; - - int i; - int max_sids; - - mem_ctx = talloc_init("lsaenum"); - - hnd = cac_NewServerHandle(True); - - printf("Enter server to connect to: "); - fscanf(stdin, "%s", hnd->server); - - if(!cac_Connect(hnd, NULL)) { - fprintf(stderr, "Could not connect to server.\n Error: %s.\n errno: %s\n", nt_errstr(hnd->status), strerror(errno)); - cac_FreeHandle(hnd); - exit(-1); - } - - printf("How many sids do you want to grab at a time? "); - fscanf(stdin, "%d", &max_sids); - - struct LsaOpenPolicy lop; - ZERO_STRUCT(lop); - - lop.in.access = SEC_RIGHT_MAXIMUM_ALLOWED; - lop.in.security_qos = True; - - - if(!cac_LsaOpenPolicy(hnd, mem_ctx, &lop)) { - fprintf(stderr, "Could not open policy handle.\n Error: %s\n", nt_errstr(hnd->status)); - cac_FreeHandle(hnd); - exit(-1); - } - - pol = lop.out.pol; - - - struct LsaEnumSids esop; - ZERO_STRUCT(esop); - esop.in.pol = pol; - /*grab a couple at a time to demonstrate multiple calls*/ - esop.in.pref_max_sids = max_sids; - - printf("Attempting to fetch SIDs %d at a time\n", esop.in.pref_max_sids); - - while(cac_LsaEnumSids(hnd, mem_ctx, &esop)) { - - printf("\nEnumerated %d sids: \n", esop.out.num_sids); - for(i = 0; i < esop.out.num_sids; i++) { - printf(" SID: %s\n", sid_string_static(&esop.out.sids[i])); - } - - printf("Resolving names\n"); - - struct LsaGetNamesFromSids gnop; - ZERO_STRUCT(gnop); - - gnop.in.pol = pol; - gnop.in.sids = esop.out.sids; - gnop.in.num_sids = esop.out.num_sids; - - if(!cac_LsaGetNamesFromSids(hnd, mem_ctx, &gnop)) { - fprintf(stderr, "Could not resolve names.\n Error: %s\n", nt_errstr(hnd->status)); - goto done; - } - - printf("\nResolved %d names: \n", gnop.out.num_found); - for(i = 0; i < gnop.out.num_found; i++) { - printf(" SID: %s\n", sid_string_static(&gnop.out.sids[i].sid)); - printf(" Name: %s\n", gnop.out.sids[i].name); - } - - /*clean up a little*/ - talloc_free(gnop.out.sids); - } - -done: - if(!cac_LsaClosePolicy(hnd, mem_ctx, pol)) { - fprintf(stderr, "Could not close policy handle.\n Error: %s\n", nt_errstr(hnd->status)); - } - - cac_FreeHandle(hnd); - talloc_destroy(mem_ctx); - - return 0; -} diff --git a/examples/libmsrpc/test/lsa/lsaenumprivs.c b/examples/libmsrpc/test/lsa/lsaenumprivs.c deleted file mode 100644 index 8b5c9deca6..0000000000 --- a/examples/libmsrpc/test/lsa/lsaenumprivs.c +++ /dev/null @@ -1,79 +0,0 @@ -/*enumerates privileges*/ - -#include "libmsrpc.h" -#include "includes.h" - -#define MAX_STRING_LEN 50; - -int main() { - CacServerHandle *hnd = NULL; - TALLOC_CTX *mem_ctx = NULL; - POLICY_HND *lsa_pol = NULL; - - int i; - - mem_ctx = talloc_init("lsatrust"); - - hnd = cac_NewServerHandle(True); - - printf("Server: "); - fscanf(stdin, "%s", hnd->server); - - printf("Connecting to server....\n"); - - if(!cac_Connect(hnd, NULL)) { - fprintf(stderr, "Could not connect to server.\n Error: %s\n errno %s\n", nt_errstr(hnd->status), strerror(errno)); - cac_FreeHandle(hnd); - exit(-1); - } - - printf("Connected to server\n"); - - struct LsaOpenPolicy lop; - ZERO_STRUCT(lop); - - lop.in.access = SEC_RIGHT_MAXIMUM_ALLOWED; - lop.in.security_qos = True; - - - if(!cac_LsaOpenPolicy(hnd, mem_ctx, &lop)) { - fprintf(stderr, "Could not open policy handle.\n Error: %s\n", nt_errstr(hnd->status)); - cac_FreeHandle(hnd); - exit(-1); - } - - lsa_pol = lop.out.pol; - - printf("Enumerating Privileges\n"); - - struct LsaEnumPrivileges ep; - ZERO_STRUCT(ep); - - ep.in.pol = lsa_pol; - ep.in.pref_max_privs = 50; - - while(cac_LsaEnumPrivileges(hnd, mem_ctx, &ep)) { - printf(" Enumerated %d privileges\n", ep.out.num_privs); - - for(i = 0; i < ep.out.num_privs; i++) { - printf("\"%s\"\n", ep.out.priv_names[i]); - } - - printf("\n"); - } - - if(CAC_OP_FAILED(hnd->status)) { - fprintf(stderr, "Error while enumerating privileges.\n Error: %s\n", nt_errstr(hnd->status)); - goto done; - } - -done: - if(!cac_LsaClosePolicy(hnd, mem_ctx, lsa_pol)) { - fprintf(stderr, "Could not close policy handle.\n Error: %s\n", nt_errstr(hnd->status)); - } - - cac_FreeHandle(hnd); - talloc_destroy(mem_ctx); - - return 0; -} diff --git a/examples/libmsrpc/test/lsa/lsapol.c b/examples/libmsrpc/test/lsa/lsapol.c deleted file mode 100644 index 58407e4343..0000000000 --- a/examples/libmsrpc/test/lsa/lsapol.c +++ /dev/null @@ -1,87 +0,0 @@ -/* simple test code, opens and closes an LSA policy handle using libmsrpc, careful.. there's no password input masking*/ - -#include "includes.h" -#include "libmsrpc.h" - -void fill_conn_info(CacServerHandle *hnd) { - pstring domain; - pstring username; - pstring password; - pstring server; - - fprintf(stdout, "Enter domain name: "); - fscanf(stdin, "%s", domain); - - fprintf(stdout, "Enter username: "); - fscanf(stdin, "%s", username); - - fprintf(stdout, "Enter password (no input masking): "); - fscanf(stdin, "%s", password); - - fprintf(stdout, "Enter server (ip or name): "); - fscanf(stdin, "%s", server); - - hnd->domain = SMB_STRDUP(domain); - hnd->username = SMB_STRDUP(username); - hnd->password = SMB_STRDUP(password); - hnd->server = SMB_STRDUP(server); -} - -int main() { - CacServerHandle *hnd = NULL; - TALLOC_CTX *mem_ctx; - struct LsaOpenPolicy op; - - mem_ctx = talloc_init("lsapol"); - - - hnd = cac_NewServerHandle(False); - - /*this line is unnecesary*/ - cac_SetAuthDataFn(hnd, cac_GetAuthDataFn); - - hnd->debug = 0; - - fill_conn_info(hnd); - - /*connect to the server, its name/ip is already in the handle so just pass NULL*/ - if(!cac_Connect(hnd, NULL)) { - fprintf(stderr, "Could not connect to server. \n Error %s\n errno(%d): %s\n", nt_errstr(hnd->status), errno, strerror(errno)); - cac_FreeHandle(hnd); - exit(-1); - } - else { - fprintf(stdout, "Connected to server\n"); - } - - op.in.access = GENERIC_EXECUTE_ACCESS; - op.in.security_qos = True; - - /*open the handle*/ - if(!cac_LsaOpenPolicy(hnd, mem_ctx, &op)) { - fprintf(stderr, "Could not open policy.\n Error: %s.errno: %d.\n", nt_errstr(hnd->status), errno); - cac_FreeHandle(hnd); - exit(-1); - } - else { - fprintf(stdout, "Opened Policy handle\n"); - } - - /*close the handle*/ - if(!cac_LsaClosePolicy(hnd, mem_ctx, op.out.pol)) { - fprintf(stderr, "Could not close policy. Error: %s\n", nt_errstr(hnd->status)); - } - else { - fprintf(stdout, "Closed Policy handle\n"); - } - - /*cleanup*/ - cac_FreeHandle(hnd); - - talloc_destroy(mem_ctx); - - fprintf(stdout, "Free'd server handle\n"); - - return 0; -} - diff --git a/examples/libmsrpc/test/lsa/lsapriv.c b/examples/libmsrpc/test/lsa/lsapriv.c deleted file mode 100644 index 80b3ea102f..0000000000 --- a/examples/libmsrpc/test/lsa/lsapriv.c +++ /dev/null @@ -1,113 +0,0 @@ -/*tries to set privileges for an account*/ - -#include "libmsrpc.h" -#include "test_util.h" - -#define BIGGEST_UINT32 0xffffffff - -int main(int argc, char **argv) { - CacServerHandle *hnd = NULL; - TALLOC_CTX *mem_ctx = NULL; - - struct LsaOpenPolicy lop; - struct LsaEnumPrivileges ep; - struct LsaEnumAccountRights ar; - struct LsaAddPrivileges ap; - - fstring tmp; - - uint32 i = 0; - - mem_ctx = talloc_init("lsapriv"); - - hnd = cac_NewServerHandle(True); - - cac_SetAuthDataFn(hnd, cactest_GetAuthDataFn); - - cac_parse_cmd_line(argc, argv, hnd); - - if(!cac_Connect(hnd, NULL)) { - fprintf(stderr, "Could not connect to server %s. Error: %s\n", hnd->server, nt_errstr(hnd->status)); - exit(-1); - } - - ZERO_STRUCT(lop); - - lop.in.access = SEC_RIGHT_MAXIMUM_ALLOWED; - - if(!cac_LsaOpenPolicy(hnd, mem_ctx, &lop)) { - fprintf(stderr, "Could not open LSA policy. Error: %s\n", nt_errstr(hnd->status)); - goto done; - } - - /*first enumerate possible privileges*/ - ZERO_STRUCT(ep); - - ep.in.pol = lop.out.pol; - ep.in.pref_max_privs = BIGGEST_UINT32; - - printf("Enumerating supported privileges:\n"); - while(cac_LsaEnumPrivileges(hnd, mem_ctx, &ep)) { - for(i = 0; i < ep.out.num_privs; i++) { - printf("\t%s\n", ep.out.priv_names[i]); - } - } - - if(CAC_OP_FAILED(hnd->status)) { - fprintf(stderr, "Could not enumerate privileges. Error: %s\n", nt_errstr(hnd->status)); - goto done; - } - - printf("Enter account name: "); - cactest_readline(stdin, tmp); - - ZERO_STRUCT(ar); - - ar.in.pol = lop.out.pol; - ar.in.name = talloc_strdup(mem_ctx, tmp); - - printf("Enumerating privileges for %s:\n", ar.in.name); - if(!cac_LsaEnumAccountRights(hnd, mem_ctx, &ar)) { - fprintf(stderr, "Could not enumerate privileges. Error: %s\n", nt_errstr(hnd->status)); - goto done; - } - - printf("Enumerated %d privileges:\n", ar.out.num_privs); - - for(i = 0; i < ar.out.num_privs; i++) - printf("\t%s\n", ar.out.priv_names[i]); - - ZERO_STRUCT(ap); - - ap.in.pol = lop.out.pol; - ap.in.name = ar.in.name; - - printf("How many privileges will you set: "); - scanf("%d", &ap.in.num_privs); - - ap.in.priv_names = talloc_array(mem_ctx, char *, ap.in.num_privs); - if(!ap.in.priv_names) { - fprintf(stderr, "No memory\n"); - goto done; - } - - for(i = 0; i < ap.in.num_privs; i++) { - printf("Enter priv %d: ", i); - cactest_readline(stdin, tmp); - - ap.in.priv_names[i] = talloc_strdup(mem_ctx, tmp); - } - - if(!cac_LsaSetPrivileges(hnd, mem_ctx, &ap)) { - fprintf(stderr, "Could not set privileges. Error: %s\n", nt_errstr(hnd->status)); - goto done; - } - -done: - talloc_destroy(mem_ctx); - cac_FreeHandle(hnd); - - return 0; - -} - diff --git a/examples/libmsrpc/test/lsa/lsaq.c b/examples/libmsrpc/test/lsa/lsaq.c deleted file mode 100644 index 54c1849bfd..0000000000 --- a/examples/libmsrpc/test/lsa/lsaq.c +++ /dev/null @@ -1,245 +0,0 @@ -/* connects to an LSA, asks for a list of server names, prints out their sids, then looks up their names from the sids and prints them out again - * if you run as lsaq -p, then it will simulate a partial success for cac_GetNamesFromSids. It will try to lookup the server's local and domain sids - */ - - -#include "libmsrpc.h" -#include "includes.h" - -void fill_conn_info(CacServerHandle *hnd) { - pstring domain; - pstring username; - pstring password; - pstring server; - - fprintf(stdout, "Enter domain name: "); - fscanf(stdin, "%s", domain); - - fprintf(stdout, "Enter username: "); - fscanf(stdin, "%s", username); - - fprintf(stdout, "Enter password (no input masking): "); - fscanf(stdin, "%s", password); - - fprintf(stdout, "Enter server (ip or name): "); - fscanf(stdin, "%s", server); - - hnd->domain = SMB_STRDUP(domain); - hnd->username = SMB_STRDUP(username); - hnd->password = SMB_STRDUP(password); - hnd->server = SMB_STRDUP(server); -} - -void get_server_names(TALLOC_CTX *mem_ctx, int *num_names, char ***names) { - int i = 0; - pstring tmp; - - fprintf(stdout, "How many names do you want to lookup?: "); - fscanf(stdin, "%d", num_names); - - *names = TALLOC_ARRAY(mem_ctx, char *, *num_names); - if(*names == NULL) { - fprintf(stderr, "No memory for allocation\n"); - exit(-1); - } - - for(i = 0; i < *num_names; i++) { - fprintf(stdout, "Enter name: "); - fscanf(stdin, "%s", tmp); - (*names)[i] = talloc_strdup(mem_ctx, tmp); - } -} - -int main(int argc, char **argv) { - int i; - int result; - char **names; - int num_names; - int num_sids; - CacServerHandle *hnd = NULL; - POLICY_HND *lsa_pol = NULL; - TALLOC_CTX *mem_ctx = NULL; - - DOM_SID *sid_buf = NULL; - - BOOL sim_partial = False; - - if(argc > 1 && strcmp(argv[1], "-p") == 0) - sim_partial = True; - - mem_ctx = talloc_init("lsaq"); - - hnd = cac_NewServerHandle(False); - - fill_conn_info(hnd); - - get_server_names(mem_ctx, &num_names, &names); - - /*connect to the PDC and open a LSA handle*/ - if(!cac_Connect(hnd, NULL)) { - fprintf(stderr, "Could not connect to server.\n Error %s.\n", nt_errstr(hnd->status)); - cac_FreeHandle(hnd); - exit(-1); - } - - fprintf(stdout, "Connected to server: %s\n", hnd->server); - - struct LsaOpenPolicy lop; - ZERO_STRUCT(lop); - - lop.in.access = SEC_RIGHT_MAXIMUM_ALLOWED; - lop.in.security_qos = True; - - if(!cac_LsaOpenPolicy(hnd, mem_ctx, &lop)) { - fprintf(stderr, "Could not get lsa policy handle.\n Error: %s\n", nt_errstr(hnd->status)); - cac_FreeHandle(hnd); - exit(-1); - } - - fprintf(stdout, "Opened Policy Handle\n"); - - /*just to make things neater*/ - lsa_pol = lop.out.pol; - - /*fetch the local sid and domain sid for the pdc*/ - - struct LsaFetchSid fsop; - ZERO_STRUCT(fsop); - - fsop.in.pol = lsa_pol; - fsop.in.info_class = (CAC_LOCAL_INFO|CAC_DOMAIN_INFO); - - fprintf(stdout, "fetching SID info for %s\n", hnd->server); - - result = cac_LsaFetchSid(hnd, mem_ctx, &fsop); - if(!result) { - fprintf(stderr, "Could not get sid for server: %s\n. Error: %s\n", hnd->server, nt_errstr(hnd->status)); - cac_FreeHandle(hnd); - talloc_destroy(mem_ctx); - exit(-1); - } - - if(result == CAC_PARTIAL_SUCCESS) { - fprintf(stdout, "could not retrieve both domain and local information\n"); - } - - - fprintf(stdout, "Fetched SID info for %s\n", hnd->server); - if(fsop.out.local_sid != NULL) - fprintf(stdout, " domain: %s. Local SID: %s\n", fsop.out.local_sid->domain, sid_string_static(&fsop.out.local_sid->sid)); - - if(fsop.out.domain_sid != NULL) - fprintf(stdout, " domain: %s, Domain SID: %s\n", fsop.out.domain_sid->domain, sid_string_static(&fsop.out.domain_sid->sid)); - - fprintf(stdout, "\nAttempting to query info policy\n"); - - struct LsaQueryInfoPolicy qop; - ZERO_STRUCT(qop); - - qop.in.pol = lsa_pol; - - if(!cac_LsaQueryInfoPolicy(hnd, mem_ctx, &qop)) { - fprintf(stderr, "Could not query information policy!.\n Error: %s\n", nt_errstr(hnd->status)); - goto done; - } - - fprintf(stdout, "Query result: \n"); - fprintf(stdout, " domain name: %s\n", qop.out.domain_name); - fprintf(stdout, " dns name: %s\n", qop.out.dns_name); - fprintf(stdout, " forest name: %s\n", qop.out.forest_name); - fprintf(stdout, " domain guid: %s\n", smb_uuid_string_static(*qop.out.domain_guid)); - fprintf(stdout, " domain sid: %s\n", sid_string_static(qop.out.domain_sid)); - - fprintf(stdout, "\nLooking up sids\n"); - - struct LsaGetSidsFromNames gsop; - ZERO_STRUCT(gsop); - - gsop.in.pol = lsa_pol; - gsop.in.num_names = num_names; - gsop.in.names = names; - - result = cac_LsaGetSidsFromNames(hnd, mem_ctx, &gsop); - - if(!result) { - fprintf(stderr, "Could not lookup any sids!\n Error: %s\n", nt_errstr(hnd->status)); - goto done; - } - - if(result == CAC_PARTIAL_SUCCESS) { - fprintf(stdout, "Not all names could be looked up.\nThe following names were not found:\n"); - - for(i = 0; i < (num_names - gsop.out.num_found); i++) { - fprintf(stdout, " %s\n", gsop.out.unknown[i]); - } - - fprintf(stdout, "\n"); - } - - /*buffer the sids so we can look them up back to names*/ - num_sids = (sim_partial) ? gsop.out.num_found + 2: gsop.out.num_found; - sid_buf = TALLOC_ARRAY(mem_ctx, DOM_SID, num_sids); - - fprintf(stdout, "%d names were resolved: \n", gsop.out.num_found); - - - i = 0; - while(i < gsop.out.num_found) { - fprintf(stdout, " Name: %s\n SID: %s\n\n", gsop.out.sids[i].name, sid_string_static(&gsop.out.sids[i].sid)); - - sid_buf[i] = gsop.out.sids[i].sid; - - i++; - } - - /*if we want a partial success to occur below, then add the server's SIDs to the end of the array*/ - if(sim_partial) { - sid_buf[i] = fsop.out.local_sid->sid; - sid_buf[i+1] = fsop.out.domain_sid->sid; - } - - fprintf(stdout, "Looking up Names from SIDs\n"); - - struct LsaGetNamesFromSids gnop; - ZERO_STRUCT(gnop); - - gnop.in.pol = lsa_pol; - gnop.in.num_sids = num_sids; - gnop.in.sids = sid_buf; - - result = cac_LsaGetNamesFromSids(hnd, mem_ctx, &gnop); - - if(!result) { - fprintf(stderr, "Could not lookup any names!.\n Error: %s\n", nt_errstr(hnd->status)); - goto done; - } - - if(result == CAC_PARTIAL_SUCCESS) { - fprintf(stdout, "\nNot all SIDs could be looked up.\n. The following SIDs were not found:\n"); - - for(i = 0; i < (num_sids - gnop.out.num_found); i++) { - fprintf(stdout, "SID: %s\n", sid_string_static(&gnop.out.unknown[i])); - } - - fprintf(stdout, "\n"); - } - - fprintf(stdout, "%d SIDs were resolved: \n", gnop.out.num_found); - for(i = 0; i < gnop.out.num_found; i++) { - fprintf(stdout, " SID: %s\n Name: %s\n", sid_string_static(&gnop.out.sids[i].sid), gsop.out.sids[i].name); - } - -done: - - if(!cac_LsaClosePolicy(hnd, mem_ctx, lsa_pol)) { - fprintf(stderr, "Could not close LSA policy handle.\n Error: %s\n", nt_errstr(hnd->status)); - } - else { - fprintf(stdout, "Closed Policy handle.\n"); - } - - cac_FreeHandle(hnd); - talloc_destroy(mem_ctx); - - return 0; -} diff --git a/examples/libmsrpc/test/lsa/lsatrust.c b/examples/libmsrpc/test/lsa/lsatrust.c deleted file mode 100644 index 6ad293f832..0000000000 --- a/examples/libmsrpc/test/lsa/lsatrust.c +++ /dev/null @@ -1,151 +0,0 @@ -/*queries trusted domain information*/ - -#include "libmsrpc.h" -#include "includes.h" - -#define MAX_STRING_LEN 50; - -void print_info(LSA_TRUSTED_DOMAIN_INFO *info) { - switch(info->info_class) { - case CAC_INFO_TRUSTED_DOMAIN_FULL_INFO: - case CAC_INFO_TRUSTED_DOMAIN_INFO_ALL: - printf(" Domain Name: %s\n", unistr2_static(&info->info_ex.domain_name.unistring)); - printf(" Netbios Name: %s\n", unistr2_static(&info->info_ex.netbios_name.unistring)); - printf(" Domain Sid: %s\n", sid_string_static(&info->info_ex.sid.sid)); - printf(" Trust direction: %d\n", info->info_ex.trust_direction); - printf(" Trust Type: %d\n", info->info_ex.trust_type); - printf(" Trust attr: %d\n", info->info_ex.trust_attributes); - printf(" Posix Offset: %d\n", info->posix_offset.posix_offset); - break; - } -} - -int main() { - CacServerHandle *hnd = NULL; - TALLOC_CTX *mem_ctx = NULL; - POLICY_HND *lsa_pol = NULL; - - int i; - - mem_ctx = talloc_init("lsatrust"); - - hnd = cac_NewServerHandle(False); - - /*malloc some memory so get_auth_data_fn can work*/ - hnd->username = SMB_MALLOC_ARRAY(char, sizeof(fstring)); - hnd->domain = SMB_MALLOC_ARRAY(char, sizeof(fstring)); - hnd->netbios_name = SMB_MALLOC_ARRAY(char, sizeof(fstring)); - hnd->password = SMB_MALLOC_ARRAY(char, sizeof(fstring)); - - hnd->server = SMB_MALLOC_ARRAY(char, sizeof(fstring)); - - - printf("Server: "); - fscanf(stdin, "%s", hnd->server); - - printf("Connecting to server....\n"); - - if(!cac_Connect(hnd, NULL)) { - fprintf(stderr, "Could not connect to server.\n Error: %s\n errno %s\n", nt_errstr(hnd->status), strerror(errno)); - cac_FreeHandle(hnd); - exit(-1); - } - - printf("Connected to server\n"); - - struct LsaOpenPolicy lop; - ZERO_STRUCT(lop); - - lop.in.access = SEC_RIGHT_MAXIMUM_ALLOWED; - lop.in.security_qos = True; - - - if(!cac_LsaOpenPolicy(hnd, mem_ctx, &lop)) { - fprintf(stderr, "Could not open policy handle.\n Error: %s\n", nt_errstr(hnd->status)); - cac_FreeHandle(hnd); - exit(-1); - } - - lsa_pol = lop.out.pol; - - printf("Enumerating Trusted Domains\n"); - - struct LsaEnumTrustedDomains etd; - ZERO_STRUCT(etd); - - etd.in.pol = lsa_pol; - - while(cac_LsaEnumTrustedDomains(hnd, mem_ctx, &etd)) { - printf(" Enumerated %d domains\n", etd.out.num_domains); - - for(i = 0; i < etd.out.num_domains; i++) { - printf(" Name: %s\n", etd.out.domain_names[i]); - printf(" SID: %s\n", sid_string_static(&etd.out.domain_sids[i])); - - printf("\n Attempting to open domain...\n"); - - struct LsaOpenTrustedDomain otd; - ZERO_STRUCT(otd); - - otd.in.pol = lsa_pol; - otd.in.domain_sid = &etd.out.domain_sids[i]; - otd.in.access = SEC_RIGHT_MAXIMUM_ALLOWED; - - /*try to query trusted domain info by name*/ - struct LsaQueryTrustedDomainInfo qtd; - ZERO_STRUCT(qtd); - - qtd.in.pol = lsa_pol; - qtd.in.domain_name = etd.out.domain_names[i]; - - - int j; - for(j = 0; j < 100; j++ ) { - qtd.in.info_class = j; - - printf(" Querying trustdom by name\n"); - if(!cac_LsaQueryTrustedDomainInfo(hnd, mem_ctx, &qtd)) { - fprintf(stderr, " could not query trusted domain info.\n Error %s\n", nt_errstr(hnd->status)); - continue; - } - - printf(" info_class %d succeeded\n", j); - printf(" Query result:\n"); - printf(" size %d\n", sizeof(*qtd.out.info)); - } - - /*try to query trusted domain info by SID*/ - printf(" Querying trustdom by sid\n"); - qtd.in.domain_sid = &etd.out.domain_sids[i]; - if(!cac_LsaQueryTrustedDomainInfo(hnd, mem_ctx, &qtd)) { - fprintf(stderr, " could not query trusted domain info.\n Error %s\n", nt_errstr(hnd->status)); - continue; - } - - printf(" Query result:\n"); -/* print_info(qtd.out.info);*/ - - if(CAC_OP_FAILED(hnd->status)) { - fprintf(stderr, " Could not enum sids.\n Error: %s\n", nt_errstr(hnd->status)); - continue; - } - } - - printf("\n"); - } - - if(CAC_OP_FAILED(hnd->status)) { - fprintf(stderr, "Error while enumerating trusted domains.\n Error: %s\n", nt_errstr(hnd->status)); - goto done; - } - -done: - if(!cac_LsaClosePolicy(hnd, mem_ctx, lsa_pol)) { - fprintf(stderr, "Could not close policy handle.\n Error: %s\n", nt_errstr(hnd->status)); - } - - cac_FreeHandle(hnd); - talloc_destroy(mem_ctx); - - return 0; -} diff --git a/examples/libmsrpc/test/reg/regdelete.c b/examples/libmsrpc/test/reg/regdelete.c deleted file mode 100644 index 50b08ba468..0000000000 --- a/examples/libmsrpc/test/reg/regdelete.c +++ /dev/null @@ -1,102 +0,0 @@ -/*tests deleting a key or value*/ - -#include "libmsrpc.h" -#include "test_util.h" - -int main(int argc, char **argv) { - CacServerHandle *hnd = NULL; - TALLOC_CTX *mem_ctx = NULL; - - fstring tmp; - char input = 'v'; - - mem_ctx = talloc_init("regdelete"); - - hnd = cac_NewServerHandle(True); - - cac_SetAuthDataFn(hnd, cactest_GetAuthDataFn); - - cac_parse_cmd_line(argc, argv, hnd); - - if(!cac_Connect(hnd, NULL)) { - fprintf(stderr, "Could not connect to server %s. Error: %s\n", hnd->server, nt_errstr(hnd->status)); - exit(-1); - } - - printf("enter key to open: \n"); - cactest_readline(stdin, tmp); - - struct RegOpenKey rok; - ZERO_STRUCT(rok); - - rok.in.name = talloc_strdup(mem_ctx, tmp); - rok.in.access = REG_KEY_ALL; - - if(!cac_RegOpenKey(hnd, mem_ctx, &rok)) { - fprintf(stderr, "Could not open key %s. Error %s\n", rok.in.name, nt_errstr(hnd->status)); - exit(-1); - } - - printf("getting version (just for testing\n"); - - struct RegGetVersion rgv; - ZERO_STRUCT(rgv); - - rgv.in.key = rok.out.key; - - if(!cac_RegGetVersion(hnd, mem_ctx, &rgv)) - fprintf(stderr, "Could not get version. Error: %s\n", nt_errstr(hnd->status)); - else - printf("Version: %d\n", rgv.out.version); - - - while(input == 'v' || input == 'k') { - printf("Delete [v]alue [k]ey or [q]uit: "); - scanf("%c", &input); - - switch(input) { - case 'v': - printf("Value to delete: "); - cactest_readline(stdin, tmp); - - struct RegDeleteValue rdv; - ZERO_STRUCT(rdv); - - rdv.in.parent_key = rok.out.key; - rdv.in.name = talloc_strdup(mem_ctx, tmp); - - if(!cac_RegDeleteValue(hnd, mem_ctx, &rdv)) - fprintf(stderr, "Could not delete value %s. Error: %s\n", rdv.in.name, nt_errstr(hnd->status)); - - break; - case 'k': - printf("Key to delete: "); - cactest_readline(stdin, tmp); - - struct RegDeleteKey rdk; - ZERO_STRUCT(rdk); - - rdk.in.parent_key = rok.out.key; - rdk.in.name = talloc_strdup(mem_ctx, tmp); - - printf("delete recursively? [y/n]: "); - cactest_readline(stdin, tmp); - - rdk.in.recursive = (tmp[0] == 'y') ? True : False; - - if(!cac_RegDeleteKey(hnd, mem_ctx, &rdk)) - fprintf(stderr, "Could not delete key %s. Error %s\n", rdk.in.name, nt_errstr(hnd->status)); - - break; - } - } - cac_RegClose(hnd, mem_ctx, rok.out.key); - - cac_FreeHandle(hnd); - - talloc_destroy(mem_ctx); - - return 0; -} - - diff --git a/examples/libmsrpc/test/reg/regkey.c b/examples/libmsrpc/test/reg/regkey.c deleted file mode 100644 index a90d06c6ef..0000000000 --- a/examples/libmsrpc/test/reg/regkey.c +++ /dev/null @@ -1,76 +0,0 @@ -/*opens and closes a key*/ - -#include "libmsrpc.h" - -int main() { - CacServerHandle *hnd = NULL; - TALLOC_CTX *mem_ctx = NULL; - - fstring key; - - mem_ctx = talloc_init("regkey"); - - hnd = cac_NewServerHandle(False); - - /*allocate some memory so get_auth_data_fn can do it's magic*/ - hnd->username = SMB_MALLOC_ARRAY(char, sizeof(fstring)); - hnd->domain = SMB_MALLOC_ARRAY(char, sizeof(fstring)); - hnd->netbios_name = SMB_MALLOC_ARRAY(char, sizeof(fstring)); - hnd->password = SMB_MALLOC_ARRAY(char, sizeof(fstring)); - - hnd->server = SMB_MALLOC_ARRAY(char, sizeof(fstring)); - - printf("Enter server to connect to: "); - fscanf(stdin, "%s", hnd->server); - - printf("Enter key to open: "); - fscanf(stdin, "%s", key); - - if(!cac_Connect(hnd, NULL)) { - fprintf(stderr, "Could not connect to server.\n Error: %s.\n errno: %s\n", nt_errstr(hnd->status), strerror(errno)); - cac_FreeHandle(hnd); - exit(-1); - } - - struct RegConnect rc; - ZERO_STRUCT(rc); - - rc.in.access = REG_KEY_ALL; - rc.in.root = HKEY_LOCAL_MACHINE; - - if(!cac_RegConnect(hnd, mem_ctx, &rc)) { - fprintf(stderr, " Could not connect to registry. %s\n", nt_errstr(hnd->status)); - goto done; - } - - printf("trying to open key %s...\n", key); - - - struct RegOpenKey rok; - ZERO_STRUCT(rok); - - rok.in.parent_key = rc.out.key; - rok.in.name = key; - rok.in.access = REG_KEY_ALL; - - if(!cac_RegOpenKey(hnd, mem_ctx, &rok)) { - fprintf(stderr, "Could not open key %s\n Error: %s\n", rok.in.name, nt_errstr(hnd->status)); - goto done; - } - - if(!cac_RegClose(hnd, mem_ctx, rok.out.key)) { - fprintf(stderr, "Could not close handle %s\n", nt_errstr(hnd->status)); - } - - if(!cac_RegClose(hnd, mem_ctx, rc.out.key)) { - fprintf(stderr, " Could not close handle. %s\n", nt_errstr(hnd->status)); - } - -done: - cac_FreeHandle(hnd); - - talloc_destroy(mem_ctx); - - return 0; - -} diff --git a/examples/libmsrpc/test/reg/regkeycreate.c b/examples/libmsrpc/test/reg/regkeycreate.c deleted file mode 100644 index 50764f1682..0000000000 --- a/examples/libmsrpc/test/reg/regkeycreate.c +++ /dev/null @@ -1,115 +0,0 @@ -/*tests creating a registry key*/ - -#include "libmsrpc.h" - -#define MAX_KEYS_PER_ENUM 3 - -int main() { - CacServerHandle *hnd = NULL; - TALLOC_CTX *mem_ctx = NULL; - - fstring key_name; - - fstring key_to_create; - - mem_ctx = talloc_init("regcreatekey"); - - hnd = cac_NewServerHandle(True); - - printf("Enter server to connect to: "); - fscanf(stdin, "%s", hnd->server); - - printf("Enter key to open: "); - fscanf(stdin, "%s", key_name); - - printf("Enter key to create: "); - fscanf(stdin, "%s", key_to_create); - - if(!cac_Connect(hnd, NULL)) { - fprintf(stderr, "Could not connect to server.\n Error: %s.\n errno: %s\n", nt_errstr(hnd->status), strerror(errno)); - cac_FreeHandle(hnd); - exit(-1); - } - - printf("trying to open key %s...\n", key_name); - - struct RegOpenKey rok; - ZERO_STRUCT(rok); - - rok.in.parent_key = NULL; - rok.in.name = key_name; - rok.in.access = REG_KEY_ALL; - - if(!cac_RegOpenKey(hnd, mem_ctx, &rok)) { - fprintf(stderr, "Could not open key %s\n Error: %s\n", rok.in.name, nt_errstr(hnd->status)); - goto done; - } - - printf("Creating key %s...\n", key_to_create); - - struct RegCreateKey rck; - ZERO_STRUCT(rck); - - rck.in.parent_key = rok.out.key; - rck.in.key_name = talloc_strdup(mem_ctx, key_to_create); - rck.in.class_name = talloc_strdup(mem_ctx, ""); - rck.in.access = REG_KEY_ALL; - - if(!cac_RegCreateKey(hnd, mem_ctx, &rck)) { - fprintf(stderr, "Could not create key. Error %s\n", nt_errstr(hnd->status)); - goto done; - } - - if(!cac_RegClose(hnd, mem_ctx, rck.out.key)) { - fprintf(stderr, "Could not close key. Error %s\n", nt_errstr(hnd->status)); - goto done; - } - - /**enumerate all the subkeys*/ - printf("Enumerating all subkeys:\n"); - - struct RegEnumKeys ek; - ZERO_STRUCT(ek); - - ek.in.key = rok.out.key; - ek.in.max_keys = 50; - - while(cac_RegEnumKeys(hnd, mem_ctx, &ek)) { - int j; - - for(j = 0; j < ek.out.num_keys; j++) { - printf(" Key name: %s\n", ek.out.key_names[j]); - } - } - - if(CAC_OP_FAILED(hnd->status)) { - fprintf(stderr, "Could not enumerate keys: %s\n", nt_errstr(hnd->status)); - goto done; - } - - printf("deleting key %s\n", key_to_create); - - struct RegDeleteKey rdk; - ZERO_STRUCT(rdk); - - rdk.in.parent_key = rok.out.key; - rdk.in.name = key_to_create; - - if(!cac_RegDeleteKey(hnd, mem_ctx, &rdk)) { - fprintf(stderr, "Could not delete key. Error %s\n", nt_errstr(hnd->status)); - } - - printf("closing key %s...\n", key_name); - - if(!cac_RegClose(hnd, mem_ctx, rok.out.key)) { - fprintf(stderr, "Could not close handle %s\n", nt_errstr(hnd->status)); - } - -done: - cac_FreeHandle(hnd); - - talloc_destroy(mem_ctx); - - return 0; - -} diff --git a/examples/libmsrpc/test/reg/regkeyenum.c b/examples/libmsrpc/test/reg/regkeyenum.c deleted file mode 100644 index f140d95723..0000000000 --- a/examples/libmsrpc/test/reg/regkeyenum.c +++ /dev/null @@ -1,99 +0,0 @@ -/*tests enumerating keys or values*/ - -#include "libmsrpc.h" - -#define MAX_KEYS_PER_ENUM 3 - -int main() { - CacServerHandle *hnd = NULL; - TALLOC_CTX *mem_ctx = NULL; - - int num_keys; - - int max_enum; - - int i; - - fstring *key_names; - - mem_ctx = talloc_init("regkeyenum"); - - hnd = cac_NewServerHandle(True); - - printf("Enter server to connect to: "); - fscanf(stdin, "%s", hnd->server); - - printf("How many keys do you want to open?: "); - fscanf(stdin, "%d", &num_keys); - - printf("How many keys per enum?: "); - fscanf(stdin, "%d", &max_enum); - - key_names = TALLOC_ARRAY(mem_ctx, fstring , num_keys); - if(!key_names) { - fprintf(stderr, "No memory\n"); - exit(-1); - } - - for(i = 0; i < num_keys; i++) { - printf("Enter key to open: "); - fscanf(stdin, "%s", key_names[i]); - } - - if(!cac_Connect(hnd, NULL)) { - fprintf(stderr, "Could not connect to server.\n Error: %s.\n errno: %s\n", nt_errstr(hnd->status), strerror(errno)); - cac_FreeHandle(hnd); - exit(-1); - } - - for(i = 0; i < num_keys; i++) { - printf("trying to open key %s...\n", key_names[i]); - - struct RegOpenKey rok; - ZERO_STRUCT(rok); - - rok.in.parent_key = NULL; - rok.in.name = key_names[i]; - rok.in.access = REG_KEY_ALL; - - if(!cac_RegOpenKey(hnd, mem_ctx, &rok)) { - fprintf(stderr, "Could not open key %s\n Error: %s\n", rok.in.name, nt_errstr(hnd->status)); - continue; - } - - /**enumerate all the subkeys*/ - printf("Enumerating all subkeys:\n"); - - struct RegEnumKeys ek; - ZERO_STRUCT(ek); - - ek.in.key = rok.out.key; - ek.in.max_keys = max_enum; - - while(cac_RegEnumKeys(hnd, mem_ctx, &ek)) { - int j; - - for(j = 0; j < ek.out.num_keys; j++) { - printf(" Key name: %s\n", ek.out.key_names[j]); - } - } - - if(CAC_OP_FAILED(hnd->status)) { - fprintf(stderr, "Could not enumerate keys: %s\n", nt_errstr(hnd->status)); - continue; - } - - printf("closing key %s...\n", key_names[i]); - - if(!cac_RegClose(hnd, mem_ctx, rok.out.key)) { - fprintf(stderr, "Could not close handle %s\n", nt_errstr(hnd->status)); - } - } - - cac_FreeHandle(hnd); - - talloc_destroy(mem_ctx); - - return 0; - -} diff --git a/examples/libmsrpc/test/reg/regopen.c b/examples/libmsrpc/test/reg/regopen.c deleted file mode 100644 index fedc52e40d..0000000000 --- a/examples/libmsrpc/test/reg/regopen.c +++ /dev/null @@ -1,66 +0,0 @@ -/*opens and closes a registry handle*/ - -#include "libmsrpc.h" - -int main() { - CacServerHandle *hnd = NULL; - TALLOC_CTX *mem_ctx = NULL; - - POLICY_HND **keys = NULL; - - char roots[4][50] = { {CAC_HKCR}, {CAC_HKLM}, {CAC_HKU}, {CAC_HKPD} }; - - int i; - - - mem_ctx = talloc_init("regopen"); - - hnd = cac_NewServerHandle(True); - - keys = TALLOC_ARRAY(mem_ctx, POLICY_HND *, 4); - - printf("Enter server to connect to: "); - fscanf(stdin, "%s", hnd->server); - - if(!cac_Connect(hnd, NULL)) { - fprintf(stderr, "Could not connect to server.\n Error: %s.\n errno: %s\n", nt_errstr(hnd->status), strerror(errno)); - cac_FreeHandle(hnd); - exit(-1); - } - - struct RegConnect rc; - ZERO_STRUCT(rc); - - rc.in.access = SEC_RIGHT_MAXIMUM_ALLOWED; - - for(i = 0; i < 4; i++) { - printf("opening: %s\n", roots[i]); - - rc.in.root = roots[i]; - - if(!cac_RegConnect(hnd, mem_ctx, &rc)) { - fprintf(stderr, " Could not connect to registry. %s\n", nt_errstr(hnd->status)); - continue; - } - - keys[i] = rc.out.key; - } - - for(i = 3; i >= 0; i--) { - if(keys[i] == NULL) - continue; - - printf("closing: %s\n", roots[i]); - - if(!cac_RegClose(hnd, mem_ctx, keys[i])) { - fprintf(stderr, " Could not close handle. %s\n", nt_errstr(hnd->status)); - } - } - - cac_FreeHandle(hnd); - - talloc_destroy(mem_ctx); - - return 0; - -} diff --git a/examples/libmsrpc/test/reg/regopenkey.c b/examples/libmsrpc/test/reg/regopenkey.c deleted file mode 100644 index 732da17ccf..0000000000 --- a/examples/libmsrpc/test/reg/regopenkey.c +++ /dev/null @@ -1,69 +0,0 @@ -/*tests cac_RegOpenKey()*/ - -#include "libmsrpc.h" - -int main() { - CacServerHandle *hnd = NULL; - TALLOC_CTX *mem_ctx = NULL; - - int num_keys; - int i; - - fstring *key_names; - - mem_ctx = talloc_init("regopenkey"); - - hnd = cac_NewServerHandle(True); - - printf("Enter server to connect to: "); - fscanf(stdin, "%s", hnd->server); - - printf("How many keys do you want to open?: "); - fscanf(stdin, "%d", &num_keys); - - key_names = TALLOC_ARRAY(mem_ctx, fstring , num_keys); - if(!key_names) { - fprintf(stderr, "No memory\n"); - exit(-1); - } - - for(i = 0; i < num_keys; i++) { - printf("Enter key to open: "); - fscanf(stdin, "%s", key_names[i]); - } - - if(!cac_Connect(hnd, NULL)) { - fprintf(stderr, "Could not connect to server.\n Error: %s.\n errno: %s\n", nt_errstr(hnd->status), strerror(errno)); - cac_FreeHandle(hnd); - exit(-1); - } - - for(i = 0; i < num_keys; i++) { - printf("trying to open key %s...\n", key_names[i]); - - struct RegOpenKey rok; - ZERO_STRUCT(rok); - - rok.in.parent_key = NULL; - rok.in.name = key_names[i]; - rok.in.access = REG_KEY_ALL; - - if(!cac_RegOpenKey(hnd, mem_ctx, &rok)) { - fprintf(stderr, "Could not open key %s\n Error: %s\n", rok.in.name, nt_errstr(hnd->status)); - continue; - } - - printf("closing key %s...\n", key_names[i]); - - if(!cac_RegClose(hnd, mem_ctx, rok.out.key)) { - fprintf(stderr, "Could not close handle %s\n", nt_errstr(hnd->status)); - } - } - - cac_FreeHandle(hnd); - - talloc_destroy(mem_ctx); - - return 0; - -} diff --git a/examples/libmsrpc/test/reg/regqueryval.c b/examples/libmsrpc/test/reg/regqueryval.c deleted file mode 100644 index 9989651898..0000000000 --- a/examples/libmsrpc/test/reg/regqueryval.c +++ /dev/null @@ -1,79 +0,0 @@ -/*tests cac_RegQueryValue()*/ - -#include "libmsrpc.h" -#include "test_util.h" - -#define MAX_KEYS_PER_ENUM 3 - -int main(int argc, char **argv) { - CacServerHandle *hnd = NULL; - TALLOC_CTX *mem_ctx = NULL; - - fstring key_name; - - fstring val_name; - - mem_ctx = talloc_init("regqueryval"); - - hnd = cac_NewServerHandle(True); - - cac_SetAuthDataFn(hnd, cactest_GetAuthDataFn); - - cac_parse_cmd_line(argc, argv, hnd); - - printf("Enter key to open: "); - fscanf(stdin, "%s", key_name); - - printf("Enter value to query: "); - fscanf(stdin, "%s", val_name); - - if(!cac_Connect(hnd, NULL)) { - fprintf(stderr, "Could not connect to server.\n Error: %s.\n errno: %s\n", nt_errstr(hnd->status), strerror(errno)); - cac_FreeHandle(hnd); - exit(-1); - } - - printf("trying to open key %s...\n", key_name); - - struct RegOpenKey rok; - ZERO_STRUCT(rok); - - rok.in.parent_key = NULL; - rok.in.name = key_name; - rok.in.access = REG_KEY_ALL; - - if(!cac_RegOpenKey(hnd, mem_ctx, &rok)) { - fprintf(stderr, "Could not open key %s\n Error: %s\n", rok.in.name, nt_errstr(hnd->status)); - goto done; - } - - struct RegQueryValue rqv; - ZERO_STRUCT(rqv); - - rqv.in.key = rok.out.key; - rqv.in.val_name = talloc_strdup(mem_ctx, val_name); - - printf("querying value %s...\n", rqv.in.val_name); - if(!cac_RegQueryValue(hnd, mem_ctx, &rqv)) { - fprintf(stderr, "Could not query value. Error: %s\n", nt_errstr(hnd->status)); - } - else { - printf("Queried value %s\n", rqv.in.val_name); - print_value(rqv.out.type, rqv.out.data); - } - - - printf("closing key %s...\n", key_name); - - if(!cac_RegClose(hnd, mem_ctx, rok.out.key)) { - fprintf(stderr, "Could not close handle %s\n", nt_errstr(hnd->status)); - } - -done: - cac_FreeHandle(hnd); - - talloc_destroy(mem_ctx); - - return 0; - -} diff --git a/examples/libmsrpc/test/reg/regsetval.c b/examples/libmsrpc/test/reg/regsetval.c deleted file mode 100644 index e7327910c2..0000000000 --- a/examples/libmsrpc/test/reg/regsetval.c +++ /dev/null @@ -1,59 +0,0 @@ -/*tests cac_RegSetVal()*/ - -#include "libmsrpc.h" -#include "test_util.h" - -int main(int argc, char **argv) { - CacServerHandle *hnd = NULL; - TALLOC_CTX *mem_ctx = NULL; - - fstring tmp; - - mem_ctx = talloc_init("regsetval"); - - hnd = cac_NewServerHandle(True); - - cac_SetAuthDataFn(hnd, cactest_GetAuthDataFn); - - cac_parse_cmd_line(argc, argv, hnd); - - if(!cac_Connect(hnd, NULL)) { - fprintf(stderr, "Could not connect to server %s. Error: %s\n", hnd->server, nt_errstr(hnd->status)); - exit(-1); - } - - printf("enter key to open: \n"); - scanf("%s", tmp); - - struct RegOpenKey rok; - ZERO_STRUCT(rok); - - rok.in.name = talloc_strdup(mem_ctx, tmp); - rok.in.access = REG_KEY_ALL; - - if(!cac_RegOpenKey(hnd, mem_ctx, &rok)) { - fprintf(stderr, "Could not open key %s. Error %s\n", rok.in.name, nt_errstr(hnd->status)); - exit(-1); - } - - struct RegSetValue rsv; - ZERO_STRUCT(rsv); - - rsv.in.key = rok.out.key; - - cactest_reg_input_val(mem_ctx, &rsv.in.type, &rsv.in.val_name, &rsv.in.value); - - if(!cac_RegSetValue(hnd, mem_ctx, &rsv)) { - fprintf(stderr, "Could not set value. Error: %s\n", nt_errstr(hnd->status)); - } - - cac_RegClose(hnd, mem_ctx, rok.out.key); - - cac_FreeHandle(hnd); - - talloc_destroy(mem_ctx); - - return 0; -} - - diff --git a/examples/libmsrpc/test/reg/regvalenum.c b/examples/libmsrpc/test/reg/regvalenum.c deleted file mode 100644 index 9778f4e2b3..0000000000 --- a/examples/libmsrpc/test/reg/regvalenum.c +++ /dev/null @@ -1,103 +0,0 @@ -/*tests enumerating registry values*/ - -#include "libmsrpc.h" -#include "test_util.h" - -#define MAX_KEYS_PER_ENUM 3 - - -int main(int argc, char **argv) { - CacServerHandle *hnd = NULL; - TALLOC_CTX *mem_ctx = NULL; - - int num_keys; - - int max_enum; - - fstring *key_names; - - int i; - - mem_ctx = talloc_init("regvalenum"); - - hnd = cac_NewServerHandle(True); - - cac_parse_cmd_line(argc, argv, hnd); - - cac_SetAuthDataFn(hnd, cactest_GetAuthDataFn); - - if(!cac_Connect(hnd, NULL)) { - fprintf(stderr, "Could not connect to server.\n Error: %s.\n errno: %s\n", nt_errstr(hnd->status), strerror(errno)); - cac_FreeHandle(hnd); - exit(-1); - } - - printf("How many keys do you want to open?: "); - fscanf(stdin, "%d", &num_keys); - - printf("How many values per enum?: "); - fscanf(stdin, "%d", &max_enum); - - key_names = TALLOC_ARRAY(mem_ctx, fstring , num_keys); - if(!key_names) { - fprintf(stderr, "No memory\n"); - exit(-1); - } - - for(i = 0; i < num_keys; i++) { - printf("Enter key to open: "); - fscanf(stdin, "%s", key_names[i]); - } - - for(i = 0; i < num_keys; i++) { - printf("trying to open key %s...\n", key_names[i]); - - struct RegOpenKey rok; - ZERO_STRUCT(rok); - - rok.in.parent_key = NULL; - rok.in.name = key_names[i]; - rok.in.access = REG_KEY_ALL; - - if(!cac_RegOpenKey(hnd, mem_ctx, &rok)) { - fprintf(stderr, "Could not open key %s\n Error: %s\n", rok.in.name, nt_errstr(hnd->status)); - continue; - } - - /**enumerate all the subkeys*/ - printf("Enumerating all values:\n"); - - struct RegEnumValues rev; - ZERO_STRUCT(rev); - - rev.in.key = rok.out.key; - rev.in.max_values = max_enum; - - while(cac_RegEnumValues(hnd, mem_ctx, &rev)) { - int j; - - for(j = 0; j < rev.out.num_values; j++) { - printf(" Value name: %s\n", rev.out.value_names[j]); - print_value(rev.out.types[j], rev.out.values[j]); - } - } - - if(CAC_OP_FAILED(hnd->status)) { - fprintf(stderr, "Could not enumerate values: %s\n", nt_errstr(hnd->status)); - continue; - } - - printf("closing key %s...\n", key_names[i]); - - if(!cac_RegClose(hnd, mem_ctx, rok.out.key)) { - fprintf(stderr, "Could not close handle %s\n", nt_errstr(hnd->status)); - } - } - - cac_FreeHandle(hnd); - - talloc_destroy(mem_ctx); - - return 0; - -} diff --git a/examples/libmsrpc/test/reg/security.c b/examples/libmsrpc/test/reg/security.c deleted file mode 100644 index 6808f8c1f3..0000000000 --- a/examples/libmsrpc/test/reg/security.c +++ /dev/null @@ -1,74 +0,0 @@ -/*tests cac_RegSetKeySecurity()*/ - -#include "libmsrpc.h" -#include "test_util.h" - -int main(int argc, char **argv) { - CacServerHandle *hnd = NULL; - TALLOC_CTX *mem_ctx = NULL; - - fstring tmp; - - mem_ctx = talloc_init("regsetval"); - - hnd = cac_NewServerHandle(True); - - cac_SetAuthDataFn(hnd, cactest_GetAuthDataFn); - - cac_parse_cmd_line(argc, argv, hnd); - - if(!cac_Connect(hnd, NULL)) { - fprintf(stderr, "Could not connect to server %s. Error: %s\n", hnd->server, nt_errstr(hnd->status)); - exit(-1); - } - - struct RegOpenKey rok; - ZERO_STRUCT(rok); - - printf("enter key to query: "); - cactest_readline(stdin, tmp); - - rok.in.name = talloc_strdup(mem_ctx, tmp); - rok.in.access = REG_KEY_ALL; - - if(!cac_RegOpenKey(hnd, mem_ctx, &rok)) { - fprintf(stderr, "Could not open key %s. Error %s\n", rok.in.name, nt_errstr(hnd->status)); - exit(-1); - } - - struct RegGetKeySecurity rks; - ZERO_STRUCT(rks); - - rks.in.key = rok.out.key; - rks.in.info_type = ALL_SECURITY_INFORMATION; - - if(!cac_RegGetKeySecurity(hnd, mem_ctx, &rks)) { - fprintf(stderr, "Could not query security for %s. Error: %s\n", rok.in.name, nt_errstr(hnd->status)); - goto done; - } - - printf("resetting key security...\n"); - - struct RegSetKeySecurity rss; - ZERO_STRUCT(rss); - - rss.in.key = rok.out.key; - rss.in.info_type = ALL_SECURITY_INFORMATION; - rss.in.size = rks.out.size; - rss.in.descriptor = rks.out.descriptor; - - if(!cac_RegSetKeySecurity(hnd, mem_ctx, &rss)) { - fprintf(stderr, "Could not set security. Error %s\n", nt_errstr(hnd->status)); - } - -done: - cac_RegClose(hnd, mem_ctx, rok.out.key); - - cac_FreeHandle(hnd); - - talloc_destroy(mem_ctx); - - return 0; -} - - diff --git a/examples/libmsrpc/test/reg/shutdown.c b/examples/libmsrpc/test/reg/shutdown.c deleted file mode 100644 index 6184fbd976..0000000000 --- a/examples/libmsrpc/test/reg/shutdown.c +++ /dev/null @@ -1,68 +0,0 @@ -/*tries to shut down a remote pc*/ - -#include "libmsrpc.h" -#include "test_util.h" - - -int main(int argc, char **argv) { - CacServerHandle *hnd = NULL; - TALLOC_CTX *mem_ctx = NULL; - - fstring tmp; - - mem_ctx = talloc_init("cac_shutdown"); - - hnd = cac_NewServerHandle(True); - - cac_SetAuthDataFn(hnd, cactest_GetAuthDataFn); - - cac_parse_cmd_line(argc, argv, hnd); - - hnd->_internal.srv_level = SRV_WIN_NT4; - - if(!cac_Connect(hnd, NULL)) { - fprintf(stderr, "Could not connect to server %s. Error: %s\n", hnd->server, nt_errstr(hnd->status)); - exit(-1); - } - - struct Shutdown s; - ZERO_STRUCT(s); - - printf("Message: "); - cactest_readline(stdin, tmp); - - s.in.message = talloc_strdup(mem_ctx, tmp); - - printf("timeout: "); - scanf("%d", &s.in.timeout); - - printf("Reboot? [y/n]: "); - cactest_readline(stdin, tmp); - - s.in.reboot = ( tmp[0] == 'y') ? True : False; - - printf("Force? [y/n]: "); - cactest_readline(stdin, tmp); - - s.in.force = (tmp[0] == 'y') ? True : False; - - if(!cac_Shutdown(hnd, mem_ctx, &s)) { - fprintf(stderr, "could not shut down server: error %s\n", nt_errstr(hnd->status)); - goto done; - } - - printf("Server %s is shutting down. Would you like to try to abort? [y/n]: ", hnd->server); - fscanf(stdin, "%s", tmp); - - if(tmp[0] == 'y') { - if(!cac_AbortShutdown(hnd, mem_ctx)) { - fprintf(stderr, "Could not abort shutdown. Error %s\n", nt_errstr(hnd->status)); - } - } - -done: - cac_FreeHandle(hnd); - talloc_destroy(mem_ctx); - - return 0; -} diff --git a/examples/libmsrpc/test/sam/adduser.c b/examples/libmsrpc/test/sam/adduser.c deleted file mode 100644 index 94482d0704..0000000000 --- a/examples/libmsrpc/test/sam/adduser.c +++ /dev/null @@ -1,92 +0,0 @@ -/*add's a user to a domain*/ -#include "libmsrpc.h" -#include "test_util.h" - -int main(int argc, char **argv) { - CacServerHandle *hnd = NULL; - TALLOC_CTX *mem_ctx = NULL; - - fstring tmp; - - struct SamOpenUser ou; - - POLICY_HND *user_hnd = NULL; - - mem_ctx = talloc_init("cac_adduser"); - - hnd = cac_NewServerHandle(True); - - cac_SetAuthDataFn(hnd, cactest_GetAuthDataFn); - - cac_parse_cmd_line(argc, argv, hnd); - - if(!cac_Connect(hnd, NULL)) { - fprintf(stderr, "Could not connect to server %s. Error: %s\n", hnd->server, nt_errstr(hnd->status)); - exit(-1); - } - - struct SamOpenDomain sod; - ZERO_STRUCT(sod); - - sod.in.access = MAXIMUM_ALLOWED_ACCESS; - - if(!cac_SamOpenDomain(hnd, mem_ctx, &sod)) { - fprintf(stderr, "Could not open domain. Error: %s\n", nt_errstr(hnd->status)); - goto done; - } - - struct SamCreateUser cdu; - ZERO_STRUCT(cdu); - - printf("Enter account name: "); - cactest_readline(stdin, tmp); - - cdu.in.dom_hnd = sod.out.dom_hnd; - cdu.in.name = talloc_strdup(mem_ctx, tmp); - cdu.in.acb_mask = ACB_NORMAL; - - if(!cac_SamCreateUser(hnd, mem_ctx, &cdu)) { - fprintf(stderr, "Could not create user %s. Error: %s\n", cdu.in.name, nt_errstr(hnd->status)); - } - - printf("would you like to delete this user? [y/n]: "); - cactest_readline(stdin, tmp); - - if(tmp[0] == 'y') { - - if(!cdu.out.user_hnd) { - ZERO_STRUCT(ou); - ou.in.dom_hnd = sod.out.dom_hnd; - ou.in.access = MAXIMUM_ALLOWED_ACCESS; - ou.in.name = talloc_strdup(mem_ctx, cdu.in.name); - - if(!cac_SamOpenUser(hnd, mem_ctx, &ou)) { - fprintf(stderr, "Could not open user for deletion. Error: %s\n", nt_errstr(hnd->status)); - } - - user_hnd = ou.out.user_hnd; - } - - else { - user_hnd = cdu.out.user_hnd; - } - - if(!cac_SamDeleteUser(hnd, mem_ctx, user_hnd)) - fprintf(stderr, "Could not delete user. Error: %s\n", nt_errstr(hnd->status)); - } - else { - printf("Nope..ok\n"); - } - - cac_SamClose(hnd, mem_ctx, sod.out.dom_hnd); - cac_SamClose(hnd, mem_ctx, sod.out.sam); - -done: - talloc_destroy(mem_ctx); - - cac_FreeHandle(hnd); - - return 0; -} - -/*TODO: add a function that will create a user and set userinfo and set the password*/ diff --git a/examples/libmsrpc/test/sam/disable.c b/examples/libmsrpc/test/sam/disable.c deleted file mode 100644 index f140bad50b..0000000000 --- a/examples/libmsrpc/test/sam/disable.c +++ /dev/null @@ -1,63 +0,0 @@ -/*disable a user*/ -#include "libmsrpc.h" -#include "test_util.h" - -int main(int argc, char **argv) { - CacServerHandle *hnd = NULL; - TALLOC_CTX *mem_ctx = NULL; - - struct SamOpenUser ou; - - fstring tmp; - - mem_ctx = talloc_init("cac_disable"); - - hnd = cac_NewServerHandle(True); - - cac_SetAuthDataFn(hnd, cactest_GetAuthDataFn); - - cac_parse_cmd_line(argc, argv, hnd); - - if(!cac_Connect(hnd, NULL)) { - fprintf(stderr, "Could not connect to server %s. Error: %s\n", hnd->server, nt_errstr(hnd->status)); - exit(-1); - } - - struct SamOpenDomain sod; - ZERO_STRUCT(sod); - - sod.in.access = MAXIMUM_ALLOWED_ACCESS; - - if(!cac_SamOpenDomain(hnd, mem_ctx, &sod)) { - fprintf(stderr, "Could not open domain. Error: %s\n", nt_errstr(hnd->status)); - goto done; - } - - ZERO_STRUCT(ou); - printf("Enter username: "); - cactest_readline(stdin, tmp); - - ou.in.name = talloc_strdup(mem_ctx, tmp); - ou.in.access = MAXIMUM_ALLOWED_ACCESS; - ou.in.dom_hnd = sod.out.dom_hnd; - - if(!cac_SamOpenUser(hnd, mem_ctx, &ou)) { - fprintf(stderr, "Could not open user. Error: %s\n", nt_errstr(hnd->status)); - goto done; - } - - /*enable the user*/ - if(!cac_SamDisableUser(hnd, mem_ctx, ou.out.user_hnd)) { - fprintf(stderr, "Could not disable user: %s\n", nt_errstr(hnd->status)); - } - -done: - cac_SamClose(hnd, mem_ctx, sod.out.dom_hnd); - - cac_FreeHandle(hnd); - - talloc_destroy(mem_ctx); - - return 0; -} - diff --git a/examples/libmsrpc/test/sam/dominfo.c b/examples/libmsrpc/test/sam/dominfo.c deleted file mode 100644 index cd2eccefba..0000000000 --- a/examples/libmsrpc/test/sam/dominfo.c +++ /dev/null @@ -1,55 +0,0 @@ -/*gets domain info and prints it out*/ - -#include "libmsrpc.h" -#include "test_util.h" - -int main(int argc, char **argv) { - CacServerHandle *hnd = NULL; - TALLOC_CTX *mem_ctx = NULL; - - mem_ctx = talloc_init("cac_dominfo"); - - hnd = cac_NewServerHandle(True); - - cac_SetAuthDataFn(hnd, cactest_GetAuthDataFn); - - cac_parse_cmd_line(argc, argv, hnd); - - if(!cac_Connect(hnd, NULL)) { - fprintf(stderr, "Could not connect to server %s. Error: %s\n", hnd->server, nt_errstr(hnd->status)); - exit(-1); - } - - struct SamOpenDomain sod; - ZERO_STRUCT(sod); - - sod.in.access = MAXIMUM_ALLOWED_ACCESS; - - if(!cac_SamOpenDomain(hnd, mem_ctx, &sod)) { - fprintf(stderr, "Could not open domain. Error: %s\n", nt_errstr(hnd->status)); - goto done; - } - - struct SamGetDomainInfo gdi; - ZERO_STRUCT(gdi); - - gdi.in.dom_hnd = sod.out.dom_hnd; - - if(!cac_SamGetDomainInfo(hnd, mem_ctx, &gdi)) { - fprintf(stderr, "Could not get domain info. Error: %s\n", nt_errstr(hnd->status)); - goto done; - } - - printf("Got domain info:\n"); - print_cac_domain_info(gdi.out.info); - -done: - cac_SamClose(hnd, mem_ctx, sod.out.dom_hnd); - - cac_FreeHandle(hnd); - - talloc_destroy(mem_ctx); - - return 0; -} - diff --git a/examples/libmsrpc/test/sam/enable.c b/examples/libmsrpc/test/sam/enable.c deleted file mode 100644 index bb91fb241c..0000000000 --- a/examples/libmsrpc/test/sam/enable.c +++ /dev/null @@ -1,64 +0,0 @@ -/*enable a user*/ - -#include "libmsrpc.h" -#include "test_util.h" - -int main(int argc, char **argv) { - CacServerHandle *hnd = NULL; - TALLOC_CTX *mem_ctx = NULL; - - struct SamOpenUser ou; - - fstring tmp; - - mem_ctx = talloc_init("cac_samgroup"); - - hnd = cac_NewServerHandle(True); - - cac_SetAuthDataFn(hnd, cactest_GetAuthDataFn); - - cac_parse_cmd_line(argc, argv, hnd); - - if(!cac_Connect(hnd, NULL)) { - fprintf(stderr, "Could not connect to server %s. Error: %s\n", hnd->server, nt_errstr(hnd->status)); - exit(-1); - } - - struct SamOpenDomain sod; - ZERO_STRUCT(sod); - - sod.in.access = MAXIMUM_ALLOWED_ACCESS; - - if(!cac_SamOpenDomain(hnd, mem_ctx, &sod)) { - fprintf(stderr, "Could not open domain. Error: %s\n", nt_errstr(hnd->status)); - goto done; - } - - ZERO_STRUCT(ou); - printf("Enter username: "); - cactest_readline(stdin, tmp); - - ou.in.name = talloc_strdup(mem_ctx, tmp); - ou.in.access = MAXIMUM_ALLOWED_ACCESS; - ou.in.dom_hnd = sod.out.dom_hnd; - - if(!cac_SamOpenUser(hnd, mem_ctx, &ou)) { - fprintf(stderr, "Could not open user. Error: %s\n", nt_errstr(hnd->status)); - goto done; - } - - /*enable the user*/ - if(!cac_SamEnableUser(hnd, mem_ctx, ou.out.user_hnd)) { - fprintf(stderr, "Could not enable user: %s\n", nt_errstr(hnd->status)); - } - -done: - cac_SamClose(hnd, mem_ctx, sod.out.dom_hnd); - - cac_FreeHandle(hnd); - - talloc_destroy(mem_ctx); - - return 0; -} - diff --git a/examples/libmsrpc/test/sam/samenum.c b/examples/libmsrpc/test/sam/samenum.c deleted file mode 100644 index f1b9ebdf84..0000000000 --- a/examples/libmsrpc/test/sam/samenum.c +++ /dev/null @@ -1,117 +0,0 @@ -/*enumerate users/groups/aliases*/ - -#include "libmsrpc.h" -#include "test_util.h" - -int main(int argc, char **argv) { - CacServerHandle *hnd = NULL; - TALLOC_CTX *mem_ctx = NULL; - - - struct SamEnumUsers eu; - struct SamEnumGroups eg; - struct SamEnumAliases ea; - - fstring tmp; - - int i; - - mem_ctx = talloc_init("cac_samenum"); - - hnd = cac_NewServerHandle(True); - - cac_SetAuthDataFn(hnd, cactest_GetAuthDataFn); - - cac_parse_cmd_line(argc, argv, hnd); - - if(!cac_Connect(hnd, NULL)) { - fprintf(stderr, "Could not connect to server %s. Error: %s\n", hnd->server, nt_errstr(hnd->status)); - exit(-1); - } - - struct SamOpenDomain sod; - ZERO_STRUCT(sod); - - sod.in.access = MAXIMUM_ALLOWED_ACCESS; - - if(!cac_SamOpenDomain(hnd, mem_ctx, &sod)) { - fprintf(stderr, "Could not open domain. Error: %s\n", nt_errstr(hnd->status)); - goto done; - } - - tmp[0] = 0x00; - while(tmp[0] != 'q') { - printf("Enumerate [u]sers, [g]roups or [a]liases or [q]uit: "); - cactest_readline(stdin, tmp); - - switch(tmp[0]) { - case 'u': - ZERO_STRUCT(eu); - - eu.in.dom_hnd = sod.out.dom_hnd; - - printf("ACB mask (can be 0): "); - scanf("%x", &eu.in.acb_mask); - - while(cac_SamEnumUsers(hnd, mem_ctx, &eu)) { - printf("Enumerated %d users:\n", eu.out.num_users); - for(i = 0; i < eu.out.num_users; i++) { - printf(" Name: %s\n", eu.out.names[i]); - printf(" RID: %d\n", eu.out.rids[i]); - } - } - - if(CAC_OP_FAILED(hnd->status)) { - printf("Could not enumerate users. Error: %s\n", nt_errstr(hnd->status)); - } - break; - case 'g': - ZERO_STRUCT(eg); - eg.in.dom_hnd = sod.out.dom_hnd; - - printf("Enumerating groups...\n"); - while(cac_SamEnumGroups(hnd, mem_ctx, &eg)) { - printf("Enumerated %d groups:\n", eg.out.num_groups); - for(i = 0; i < eg.out.num_groups; i++) { - printf("RID: %d\n", eg.out.rids[i]); - printf("Name: %s\n", eg.out.names[i]); - printf("Desc: %s\n", eg.out.descriptions[i]); - } - } - - if(CAC_OP_FAILED(hnd->status)) { - printf("Could not enumerate Groups. Error: %s\n", nt_errstr(hnd->status)); - } - break; - case 'a': - ZERO_STRUCT(ea); - ea.in.dom_hnd = sod.out.dom_hnd; - - printf("Enumerating Aliases...\n"); - while(cac_SamEnumAliases(hnd, mem_ctx, &ea)) { - printf("Enumerated %d aliases:\n", ea.out.num_aliases); - - for(i = 0; i < ea.out.num_aliases; i++) { - printf("RID: %d\n", ea.out.rids[i]); - printf("Name: %s\n", ea.out.names[i]); - printf("Desc: %s\n", ea.out.descriptions[i]); - } - } - if(CAC_OP_FAILED(hnd->status)) { - printf("Could not enumerate Aliases. Error: %s\n", nt_errstr(hnd->status)); - } - break; - } - } - - cac_SamClose(hnd, mem_ctx, sod.out.dom_hnd); - cac_SamClose(hnd, mem_ctx, sod.out.sam); - -done: - talloc_destroy(mem_ctx); - cac_FreeHandle(hnd); - - return 0; - -} - diff --git a/examples/libmsrpc/test/sam/samgroup.c b/examples/libmsrpc/test/sam/samgroup.c deleted file mode 100644 index 39d9fa1137..0000000000 --- a/examples/libmsrpc/test/sam/samgroup.c +++ /dev/null @@ -1,480 +0,0 @@ -/*Some group management stuff*/ - -#include "libmsrpc.h" -#include "test_util.h" - -int main(int argc, char **argv) { - CacServerHandle *hnd = NULL; - TALLOC_CTX *mem_ctx = NULL; - - - struct SamEnumGroups eg; - struct SamEnumUsers eu; - struct SamCreateGroup cg; - struct SamOpenGroup og; - struct SamGetGroupMembers ggm; - struct SamGetNamesFromRids gn; - struct SamAddGroupMember add; - struct SamRemoveGroupMember del; - struct SamSetGroupMembers set; - struct SamGetGroupsForUser gg; - struct SamOpenUser ou; - struct SamGetGroupInfo gi; - struct SamSetGroupInfo si; - struct SamRenameGroup rg; - struct SamGetSecurityObject gso; - - POLICY_HND *group_hnd = NULL; - - fstring tmp; - fstring input; - - int i; - - mem_ctx = talloc_init("cac_samgroup"); - - hnd = cac_NewServerHandle(True); - - cac_parse_cmd_line(argc, argv, hnd); - - if(!cac_Connect(hnd, NULL)) { - fprintf(stderr, "Could not connect to server %s. Error: %s\n", hnd->server, nt_errstr(hnd->status)); - exit(-1); - } - - struct SamOpenDomain sod; - ZERO_STRUCT(sod); - - sod.in.access = MAXIMUM_ALLOWED_ACCESS; - - if(!cac_SamOpenDomain(hnd, mem_ctx, &sod)) { - fprintf(stderr, "Could not open domain. Error: %s\n", nt_errstr(hnd->status)); - goto done; - } - - tmp[0] = 0x00; - while(tmp[0] != 'q') { - printf("\n"); - printf("[l]ist groups\n"); - printf("[c]reate group\n"); - printf("[o]pen group\n"); - printf("[d]elete group\n"); - printf("list [m]embers\n"); - printf("list [u]sers\n"); - printf("list [g]roup for users\n"); - printf("[a]dd member\n"); - printf("[r]emove member\n"); - printf("[x] clear members\n"); - printf("get group [i]nfo\n"); - printf("[e]dit group info\n"); - printf("[s]et members\n"); - printf("re[n]ame group\n"); - printf("[z] close group\n"); - printf("[t] get security info\n"); - - printf("[q]uit\n\n"); - printf("Enter option: "); - cactest_readline(stdin, tmp); - - printf("\n"); - - switch(tmp[0]) { - case 'c': /*create group*/ - if(group_hnd != NULL) { - /*then we have an open handle.. close it*/ - cac_SamClose(hnd, mem_ctx, group_hnd); - group_hnd = NULL; - } - - printf("Enter group name: "); - cactest_readline(stdin, input); - - ZERO_STRUCT(cg); - - cg.in.name = talloc_strdup(mem_ctx, input); - cg.in.access = MAXIMUM_ALLOWED_ACCESS; - cg.in.dom_hnd = sod.out.dom_hnd; - - if(!cac_SamCreateGroup(hnd, mem_ctx, &cg)) { - fprintf(stderr, "Could not create group. Error: %s\n", nt_errstr(hnd->status)); - } - else { - printf("Created group %s\n", cg.in.name); - - group_hnd = cg.out.group_hnd; - } - break; - - case 'o': /*open group*/ - if(group_hnd != NULL) { - /*then we have an open handle.. close it*/ - cac_SamClose(hnd, mem_ctx, group_hnd); - group_hnd = NULL; - } - - ZERO_STRUCT(og); - - og.in.dom_hnd = sod.out.dom_hnd; - og.in.access = MAXIMUM_ALLOWED_ACCESS; - - printf("Enter RID: 0x"); - scanf("%x", &og.in.rid); - - if(!cac_SamOpenGroup(hnd, mem_ctx, &og)) { - fprintf(stderr, "Could not open group. Error: %s\n", nt_errstr(hnd->status)); - } - else { - printf("Opened group\n"); - group_hnd = og.out.group_hnd; - } - - break; - - case 'l': /*list groups*/ - ZERO_STRUCT(eg); - eg.in.dom_hnd = sod.out.dom_hnd; - - while(cac_SamEnumGroups(hnd, mem_ctx, &eg)) { - for(i = 0; i < eg.out.num_groups; i++) { - printf("RID: 0x%x Name: %s\n", eg.out.rids[i], eg.out.names[i]); - } - } - - if(CAC_OP_FAILED(hnd->status)) { - printf("Could not enumerate Groups. Error: %s\n", nt_errstr(hnd->status)); - } - - break; - - case 'm': /*list group members*/ - if(!group_hnd) { - printf("Must open group first!\n"); - break; - } - - ZERO_STRUCT(ggm); - ggm.in.group_hnd = group_hnd; - - if(!cac_SamGetGroupMembers(hnd, mem_ctx, &ggm)) { - fprintf(stderr, "Could not get group members. Error: %s\n", nt_errstr(hnd->status)); - break; - } - - printf("Group has %d members:\n", ggm.out.num_members); - - if(ggm.out.num_members == 0) /*just skip the rest of this case*/ - break; - - /**get the user names*/ - gn.in.dom_hnd = sod.out.dom_hnd; - gn.in.num_rids = ggm.out.num_members; - gn.in.rids = ggm.out.rids; - - if(!cac_SamGetNamesFromRids(hnd, mem_ctx, &gn)) { - fprintf(stderr, "Could not lookup names. Error: %s\n", nt_errstr(hnd->status)); - break; - } - - for(i = 0; i < gn.out.num_names; i++) { - printf("RID: 0x%x Name: %s\n", gn.out.map[i].rid, gn.out.map[i].name); - } - - break; - - case 'd': /*delete group*/ - if(!group_hnd) { - printf("Must open group first!\n"); - break; - } - - if(!cac_SamDeleteGroup(hnd, mem_ctx, group_hnd)) { - fprintf(stderr, "Could not delete group. Error: %s\n", nt_errstr(hnd->status)); - } - else { - printf("Deleted group.\n"); - group_hnd = NULL; - } - break; - - case 'u': /*list users*/ - ZERO_STRUCT(eu); - - eu.in.dom_hnd = sod.out.dom_hnd; - - while(cac_SamEnumUsers(hnd, mem_ctx, &eu)) { - for(i = 0; i < eu.out.num_users; i++) { - printf(" RID: 0x%x Name: %s\n", eu.out.rids[i], eu.out.names[i]); - } - } - - if(CAC_OP_FAILED(hnd->status)) { - printf("Could not enumerate users. Error: %s\n", nt_errstr(hnd->status)); - } - - break; - - case 'a': /*add member to group*/ - if(!group_hnd) { - printf("Must open group first!\n"); - break; - } - - ZERO_STRUCT(add); - - add.in.group_hnd = group_hnd; - - printf("Enter user RID: 0x"); - scanf("%x", &add.in.rid); - - if(!cac_SamAddGroupMember(hnd, mem_ctx, &add)) { - fprintf(stderr, "Could not add user to group. Error: %s\n", nt_errstr(hnd->status)); - } - else { - printf("Successfully added user to group\n"); - } - break; - - case 'r': /*remove user from group*/ - if(!group_hnd) { - printf("Must open group first!\n"); - break; - } - - ZERO_STRUCT(del); - del.in.group_hnd = group_hnd; - - printf("Enter RID: 0x"); - scanf("%x", &del.in.rid); - - if(!cac_SamRemoveGroupMember(hnd, mem_ctx, &del)) { - fprintf(stderr, "Could not remove user from group. Error: %s\n", nt_errstr(hnd->status)); - } - else { - printf("Removed user from group.\n"); - } - - break; - - case 'x': /*clear group members*/ - if(!group_hnd) { - printf("Must open group first!\n"); - break; - } - - if(!cac_SamClearGroupMembers(hnd, mem_ctx, group_hnd)) { - fprintf(stderr, "Could not clear group members. Error: %s\n", nt_errstr(hnd->status)); - } - else { - printf("Cleared group members\n"); - } - - break; - - case 's': /*set members*/ - if(!group_hnd) { - printf("Must open group first!\n"); - break; - } - - ZERO_STRUCT(set); - - set.in.group_hnd = group_hnd; - - printf("Enter the number of members: "); - scanf("%d", &set.in.num_members); - - set.in.rids = TALLOC_ARRAY(mem_ctx, uint32, set.in.num_members); - - for(i = 0; i < set.in.num_members; i++) { - printf("Enter RID #%d: 0x", (i+1)); - scanf("%x", (set.in.rids + i)); - } - - if(!cac_SamSetGroupMembers(hnd, mem_ctx, &set)) { - printf("could not set members. Error: %s\n", nt_errstr(hnd->status)); - } - else { - printf("Set users\n"); - } - - break; - - case 'g': /*list groups for user*/ - ZERO_STRUCT(ou); - ZERO_STRUCT(gg); - - printf("Enter username: "); - cactest_readline(stdin, input); - - if(input[0] != '\0') { - ou.in.name = talloc_strdup(mem_ctx, input); - } - else { - printf("Enter RID: 0x"); - scanf("%x", &ou.in.rid); - } - - ou.in.access = MAXIMUM_ALLOWED_ACCESS; - ou.in.dom_hnd = sod.out.dom_hnd; - - if(!cac_SamOpenUser(hnd, mem_ctx, &ou)) { - fprintf(stderr, "Could not open user %s. Error: %s\n", ou.in.name, nt_errstr(hnd->status)); - break; - } - - /*now find the groups*/ - gg.in.user_hnd = ou.out.user_hnd; - - if(!cac_SamGetGroupsForUser(hnd, mem_ctx, &gg)) { - fprintf(stderr, "Could not get groups for user. Error: %s\n", nt_errstr(hnd->status)); - break; - } - - cac_SamClose(hnd, mem_ctx, ou.out.user_hnd); - - ZERO_STRUCT(gn); - - gn.in.dom_hnd = sod.out.dom_hnd; - gn.in.num_rids = gg.out.num_groups; - gn.in.rids = gg.out.rids; - - if(!cac_SamGetNamesFromRids(hnd, mem_ctx, &gn)) { - fprintf(stderr, "Could not get names from RIDs. Error: %s\n", nt_errstr(hnd->status)); - break; - } - - printf("%d groups: \n", gn.out.num_names); - - for(i = 0; i < gn.out.num_names; i++) { - printf("RID: 0x%x ", gn.out.map[i].rid); - - if(gn.out.map[i].found) - printf("Name: %s\n", gn.out.map[i].name); - else - printf("Unknown RID\n"); - } - - break; - - case 'z': /*close group*/ - if(!group_hnd) { - printf("Must open group first!\n"); - break; - } - - if(!cac_SamClose(hnd, mem_ctx, group_hnd)) { - printf("Could not close group\n"); - break; - } - - group_hnd = NULL; - break; - - case 'i': /*get group info*/ - if(!group_hnd) { - printf("Must open group first!\n"); - break; - } - - ZERO_STRUCT(gi); - gi.in.group_hnd = group_hnd; - - if(!cac_SamGetGroupInfo(hnd, mem_ctx, &gi)) { - printf("Could not get group info. Error: %s\n", nt_errstr(hnd->status)); - } - else { - printf("Retrieved Group info\n"); - print_cac_group_info(gi.out.info); - } - - break; - - case 'e': /*edit group info*/ - if(!group_hnd) { - printf("Must open group first!\n"); - break; - } - - ZERO_STRUCT(gi); - ZERO_STRUCT(si); - - gi.in.group_hnd = group_hnd; - - if(!cac_SamGetGroupInfo(hnd, mem_ctx, &gi)) { - printf("Could not get group info. Error: %s\n", nt_errstr(hnd->status)); - break; - } - - edit_cac_group_info(mem_ctx, gi.out.info); - - si.in.group_hnd = group_hnd; - si.in.info = gi.out.info; - - if(!cac_SamSetGroupInfo(hnd, mem_ctx, &si)) { - printf("Could not set group info. Error: %s\n", nt_errstr(hnd->status)); - } - else { - printf(" Done.\n"); - } - - break; - - case 'n': /*rename group*/ - if(!group_hnd) { - printf("Must open group first!\n"); - break; - } - - ZERO_STRUCT(rg); - - printf("Enter new group name: "); - cactest_readline(stdin, tmp); - - rg.in.group_hnd = group_hnd; - rg.in.new_name = talloc_strdup(mem_ctx, tmp); - - if(!cac_SamRenameGroup(hnd, mem_ctx, &rg)) - printf("Could not rename group. Error: %s\n", nt_errstr(hnd->status)); - else - printf("Done.\n"); - - break; - case 't': /*get security info*/ - if(!group_hnd) { - printf("Must open group first!\n"); - break; - } - - ZERO_STRUCT(gso); - - gso.in.pol = group_hnd; - - if(!cac_SamGetSecurityObject(hnd, mem_ctx, &gso)) { - printf("Could not get security descriptor info. Error: %s\n", nt_errstr(hnd->status)); - } - else { - printf("Got it.\n"); - } - break; - - case 'q': - break; - - default: - printf("Invalid command\n"); - } - } - - cac_SamClose(hnd, mem_ctx, sod.out.dom_hnd); - - if(group_hnd) - cac_SamClose(hnd, mem_ctx, group_hnd); - -done: - cac_FreeHandle(hnd); - - talloc_destroy(mem_ctx); - - return 0; -} - diff --git a/examples/libmsrpc/test/sam/samlookup.c b/examples/libmsrpc/test/sam/samlookup.c deleted file mode 100644 index 32be50d4b9..0000000000 --- a/examples/libmsrpc/test/sam/samlookup.c +++ /dev/null @@ -1,140 +0,0 @@ -/*lookup names or rids*/ - -#include "libmsrpc.h" -#include "test_util.h" - -int main(int argc, char **argv) { - CacServerHandle *hnd = NULL; - TALLOC_CTX *mem_ctx = NULL; - - - struct SamGetNamesFromRids sgn; - struct SamGetRidsFromNames sgr; - - fstring tmp; - fstring input; - - int i; - - mem_ctx = talloc_init("cac_samenum"); - - hnd = cac_NewServerHandle(True); - - cac_parse_cmd_line(argc, argv, hnd); - - if(!cac_Connect(hnd, NULL)) { - fprintf(stderr, "Could not connect to server %s. Error: %s\n", hnd->server, nt_errstr(hnd->status)); - exit(-1); - } - - struct SamOpenDomain sod; - ZERO_STRUCT(sod); - - sod.in.access = MAXIMUM_ALLOWED_ACCESS; - - if(!cac_SamOpenDomain(hnd, mem_ctx, &sod)) { - fprintf(stderr, "Could not open domain. Error: %s\n", nt_errstr(hnd->status)); - goto done; - } - - tmp[0] = 0x00; - while(tmp[0] != 'q') { - printf("get [n]ames or get [r]ids or [q]uit: "); - cactest_readline(stdin, tmp); - - switch(tmp[0]) { - case 'n': - ZERO_STRUCT(sgn); - - sgn.in.dom_hnd = sod.out.dom_hnd; - - printf("How many rids will you enter: "); - scanf("%d", &sgn.in.num_rids); - - sgn.in.rids = talloc_array(mem_ctx, int, sgn.in.num_rids); - - for(i = 0; i < sgn.in.num_rids; i++) { - printf(" Enter RID %d: 0x", i); - scanf("%x", &sgn.in.rids[i]); - } - - printf("Getting names...\n"); - - if(!cac_SamGetNamesFromRids(hnd, mem_ctx, &sgn)) { - fprintf(stderr, "could not lookup names. Error: %s\n", nt_errstr(hnd->status)); - talloc_free(sgn.in.rids); - continue; - } - - printf("Found %d names:\n", sgn.out.num_names); - - for(i = 0; i < sgn.out.num_names; i++) { - printf(" RID: 0x%x ", sgn.out.map[i].rid); - - if(sgn.out.map[i].found) { - printf("Name: %s\n", sgn.out.map[i].name); - } - else { - printf("Unknown RID\n"); - } - - } - - break; - - case 'r': - ZERO_STRUCT(sgr); - - sgr.in.dom_hnd = sod.out.dom_hnd; - - printf("How many names will you enter: "); - scanf("%d", &sgr.in.num_names); - - sgr.in.names = talloc_array(mem_ctx, char *, sgr.in.num_names); - - for(i = 0; i < sgr.in.num_names; i++) { - printf(" Enter name %d: ", (i+1)); - cactest_readline(stdin, input); - - sgr.in.names[i] = talloc_strdup(mem_ctx, input); - } - - if(!cac_SamGetRidsFromNames(hnd, mem_ctx, &sgr)) { - fprintf(stderr, "Could not lookup names. Error: %s\n", nt_errstr(hnd->status)); - continue; - } - - printf("Found %d RIDs:\n", sgr.out.num_rids); - - for(i = 0; i < sgr.out.num_rids; i++) { - printf(" Name: %s ", sgr.out.map[i].name); - - if(sgr.out.map[i].found) { - printf("RID: 0x%x\n", sgr.out.map[i].rid); - } - else { - printf("Unknown name\n"); - } - } - - break; - case 'q': - printf("\n"); - break; - default: - printf("Invalid command!\n"); - } - } - - - cac_SamClose(hnd, mem_ctx, sod.out.dom_hnd); - cac_SamClose(hnd, mem_ctx, sod.out.sam); - -done: - talloc_destroy(mem_ctx); - cac_FreeHandle(hnd); - - return 0; - -} - diff --git a/examples/libmsrpc/test/sam/samuser.c b/examples/libmsrpc/test/sam/samuser.c deleted file mode 100644 index df56a2d991..0000000000 --- a/examples/libmsrpc/test/sam/samuser.c +++ /dev/null @@ -1,294 +0,0 @@ -/*Some user management stuff*/ - -#include "libmsrpc.h" -#include "test_util.h" - -int main(int argc, char **argv) { - CacServerHandle *hnd = NULL; - TALLOC_CTX *mem_ctx = NULL; - - - struct SamOpenUser ou; - struct SamEnumUsers eu; - struct SamCreateUser cu; - struct SamGetUserInfo gi; - struct SamSetUserInfo si; - struct SamRenameUser ru; - struct SamSetPassword sp; - - POLICY_HND *user_hnd = NULL; - - fstring tmp; - fstring input; - - char *pass1 = NULL; - char *pass2 = NULL; - - int i; - - mem_ctx = talloc_init("cac_samgroup"); - - hnd = cac_NewServerHandle(True); - - cac_SetAuthDataFn(hnd, cactest_GetAuthDataFn); - - cac_parse_cmd_line(argc, argv, hnd); - - if(!cac_Connect(hnd, NULL)) { - fprintf(stderr, "Could not connect to server %s. Error: %s\n", hnd->server, nt_errstr(hnd->status)); - exit(-1); - } - - struct SamOpenDomain sod; - ZERO_STRUCT(sod); - - sod.in.access = MAXIMUM_ALLOWED_ACCESS; - - if(!cac_SamOpenDomain(hnd, mem_ctx, &sod)) { - fprintf(stderr, "Could not open domain. Error: %s\n", nt_errstr(hnd->status)); - goto done; - } - - tmp[0] = 0x00; - while(tmp[0] != 'q') { - printf("\n"); - printf("[l]ist users\n"); - printf("[c]reate user\n"); - printf("[o]pen user\n"); - printf("[d]elete user\n"); - printf("[g]et user info\n"); - printf("[e]dit user info\n"); - printf("[r]ename user\n"); - printf("reset [p]assword\n"); - printf("[n] close user\n"); - - printf("[q]uit\n\n"); - printf("Enter option: "); - cactest_readline(stdin, tmp); - - printf("\n"); - - switch(tmp[0]) { - case 'c': /*create user*/ - if(user_hnd != NULL) { - /*then we have an open handle.. close it*/ - cac_SamClose(hnd, mem_ctx, user_hnd); - user_hnd = NULL; - } - - printf("Enter user name: "); - cactest_readline(stdin, input); - - ZERO_STRUCT(cu); - - cu.in.name = talloc_strdup(mem_ctx, input); - cu.in.dom_hnd = sod.out.dom_hnd; - cu.in.acb_mask = ACB_NORMAL; - - if(!cac_SamCreateUser(hnd, mem_ctx, &cu)) { - printf("Could not create user. Error: %s\n", nt_errstr(hnd->status)); - } - else { - printf("Created user %s with RID 0x%x\n", cu.in.name, cu.out.rid); - user_hnd = cu.out.user_hnd; - } - - break; - - case 'o': /*open group*/ - if(user_hnd != NULL) { - /*then we have an open handle.. close it*/ - cac_SamClose(hnd, mem_ctx, user_hnd); - user_hnd = NULL; - } - - ZERO_STRUCT(ou); - - ou.in.dom_hnd = sod.out.dom_hnd; - ou.in.access = MAXIMUM_ALLOWED_ACCESS; - - printf("Enter RID: 0x"); - scanf("%x", &ou.in.rid); - - if(!cac_SamOpenUser(hnd, mem_ctx, &ou)) { - fprintf(stderr, "Could not open user. Error: %s\n", nt_errstr(hnd->status)); - } - else { - printf("Opened user\n"); - user_hnd = ou.out.user_hnd; - } - - break; - - case 'l': /*list users*/ - ZERO_STRUCT(eu); - eu.in.dom_hnd = sod.out.dom_hnd; - - while(cac_SamEnumUsers(hnd, mem_ctx, &eu)) { - for(i = 0; i < eu.out.num_users; i++) { - printf("RID: 0x%x Name: %s\n", eu.out.rids[i], eu.out.names[i]); - } - } - - if(CAC_OP_FAILED(hnd->status)) { - printf("Could not enumerate Users. Error: %s\n", nt_errstr(hnd->status)); - } - - break; - - break; - - case 'd': /*delete group*/ - if(!user_hnd) { - printf("Must open group first!\n"); - break; - } - - if(!cac_SamDeleteGroup(hnd, mem_ctx, user_hnd)) { - fprintf(stderr, "Could not delete group. Error: %s\n", nt_errstr(hnd->status)); - } - else { - printf("Deleted group.\n"); - user_hnd = NULL; - } - break; - - - case 'n': - if(!user_hnd) { - printf("Must open user first!\n"); - break; - } - - if(!cac_SamClose(hnd, mem_ctx, user_hnd)) { - printf("Could not user group\n"); - break; - } - - user_hnd = NULL; - break; - - case 'g': /*get user info*/ - if(!user_hnd) { - printf("Must open user first!\n"); - break; - } - - ZERO_STRUCT(gi); - gi.in.user_hnd = ou.out.user_hnd; - - if(!cac_SamGetUserInfo(hnd, mem_ctx, &gi)) { - printf("Could not get user info. Error: %s\n", nt_errstr(hnd->status)); - } - else { - printf("Retrieved User information:\n"); - print_cac_user_info(gi.out.info); - } - - break; - - case 'e': /*edit user info*/ - if(!user_hnd) { - printf("Must Open user first!\n"); - break; - } - - ZERO_STRUCT(gi); - gi.in.user_hnd = ou.out.user_hnd; - if(!cac_SamGetUserInfo(hnd, mem_ctx, &gi)) { - printf("Could not get user info. Error: %s\n", nt_errstr(hnd->status)); - break; - } - - edit_cac_user_info(mem_ctx, gi.out.info); - - printf("setting following info:\n"); - print_cac_user_info(gi.out.info); - - ZERO_STRUCT(si); - - si.in.user_hnd = user_hnd; - si.in.info = gi.out.info; - - if(!cac_SamSetUserInfo(hnd, mem_ctx, &si)) { - printf("Could not set user info. Error: %s\n", nt_errstr(hnd->status)); - } - else { - printf("Done.\n"); - } - - break; - - case 'r': /*rename user*/ - if(!user_hnd) { - printf("Must open user first!\n"); - break; - } - - ZERO_STRUCT(ru); - - printf("Enter new username: "); - cactest_readline(stdin, tmp); - - ru.in.user_hnd = user_hnd; - ru.in.new_name = talloc_strdup(mem_ctx, tmp); - - if(!cac_SamRenameUser(hnd, mem_ctx, &ru)) { - printf("Could not rename user. Error: %s\n", nt_errstr(hnd->status)); - } - else { - printf("Renamed user\n"); - } - - break; - - case 'p': /*reset password*/ - - if(!user_hnd) { - printf("Must open user first!\n"); - break; - } - - do { - if(pass1 && pass2) { - printf("Passwords do not match. Please try again\n"); - } - - pass1 = getpass("Enter new password: "); - pass2 = getpass("Re-enter new password: "); - } while(strncmp(pass1, pass2, MAX_PASS_LEN)); - - ZERO_STRUCT(sp); - sp.in.user_hnd = user_hnd; - sp.in.password = talloc_strdup(mem_ctx, pass1); - - if(!cac_SamSetPassword(hnd, mem_ctx, &sp)) { - printf("Could not set password. Error: %s\n", nt_errstr(hnd->status)); - } - else { - printf("Done.\n"); - } - - break; - - case 'q': - break; - - default: - printf("Invalid command\n"); - } - } - - cac_SamClose(hnd, mem_ctx, sod.out.dom_hnd); - - if(user_hnd) - cac_SamClose(hnd, mem_ctx, user_hnd); - -done: - cac_FreeHandle(hnd); - - talloc_destroy(mem_ctx); - - return 0; -} - diff --git a/examples/libmsrpc/test/smbc_test/smbc.c b/examples/libmsrpc/test/smbc_test/smbc.c deleted file mode 100644 index 3db3ceadc6..0000000000 --- a/examples/libmsrpc/test/smbc_test/smbc.c +++ /dev/null @@ -1,87 +0,0 @@ -/*simple test for libsmbclient compatibility. initialize a smbc context, open sessions on a couple pipes and quit*/ - -#include "libmsrpc.h" -#include "libsmbclient.h" -#include "test_util.h" - -int main(int argc, char **argv) { - SMBCCTX *ctx = NULL; - CacServerHandle *hnd = NULL; - TALLOC_CTX *mem_ctx = NULL; - - struct LsaOpenPolicy lop; - struct RegConnect rc; - struct SamOpenDomain sod; - - ZERO_STRUCT(lop); - ZERO_STRUCT(rc); - ZERO_STRUCT(sod); - - mem_ctx = talloc_init("cac_smbc"); - if(!mem_ctx) { - printf("Could not initialize talloc context\n"); - exit(-1); - } - - hnd = cac_NewServerHandle(True); - - cac_parse_cmd_line(argc, argv, hnd); - - /*initialize smbc context*/ - if( (ctx = smbc_new_context()) == NULL) { - exit(1); - } - - /*this probably isn't what someone would want to do, but it initializes the values we need*/ - ctx->debug = hnd->debug; - ctx->callbacks.auth_fn = cac_GetAuthDataFn; - - - if(smbc_init_context(ctx) == NULL) - exit(1); - - cac_SetSmbcContext(hnd, ctx); - - /*still have to call cac_Connect()*/ - if(!cac_Connect(hnd, NULL)) { - printf("Could not connect to server\n"); - exit(1); - } - - lop.in.access = MAXIMUM_ALLOWED_ACCESS; - if(!cac_LsaOpenPolicy(hnd, mem_ctx, &lop)) - printf("Could not open LSA policy. Error: %s\n", nt_errstr(hnd->status)); - - printf("Opened LSA policy.\n"); - - rc.in.access = MAXIMUM_ALLOWED_ACCESS; - rc.in.root = HKEY_LOCAL_MACHINE; - if(!cac_RegConnect(hnd, mem_ctx, &rc)) - printf("Could not connect to registry. Error: %s\n", nt_errstr(hnd->status)); - - printf("Connceted to Registry.\n"); - - sod.in.access = MAXIMUM_ALLOWED_ACCESS; - - if(!cac_SamOpenDomain(hnd, mem_ctx, &sod)) - printf("Could not open domain SAM. Error: %s\n", nt_errstr(hnd->status)); - - printf("Opened domain.\n"); - - if(lop.out.pol) - cac_LsaClosePolicy(hnd, mem_ctx, lop.out.pol); - - if(rc.out.key) - cac_RegClose(hnd, mem_ctx, rc.out.key); - - if(sod.out.sam) - cac_SamClose(hnd, mem_ctx, sod.out.sam); - - if(sod.out.dom_hnd) - cac_SamClose(hnd, mem_ctx, sod.out.dom_hnd); - - cac_FreeHandle(hnd); - talloc_destroy(mem_ctx); - - return 0; -} diff --git a/examples/libmsrpc/test/svcctl/svc.c b/examples/libmsrpc/test/svcctl/svc.c deleted file mode 100644 index db5fa27895..0000000000 --- a/examples/libmsrpc/test/svcctl/svc.c +++ /dev/null @@ -1,303 +0,0 @@ -/*Tests all of the svcctl calls (at least at time of writing)*/ - -#include "libmsrpc.h" -#include "test_util.h" - -int main(int argc, char **argv) { - CacServerHandle *hnd = NULL; - TALLOC_CTX *mem_ctx = NULL; - - - struct SvcOpenScm sos; - struct SvcEnumServices es; - struct SvcOpenService os; - struct SvcGetStatus gs; - struct SvcStartService start; - struct SvcStopService stop; - struct SvcPauseService pause; - struct SvcContinueService res; - struct SvcGetDisplayName gdn; - struct SvcGetServiceConfig sgc; - - POLICY_HND *svc_hnd = NULL; - - fstring tmp; - fstring input; - - int i; - - mem_ctx = talloc_init("cac_samgroup"); - - hnd = cac_NewServerHandle(True); - - cac_SetAuthDataFn(hnd, cactest_GetAuthDataFn); - - cac_parse_cmd_line(argc, argv, hnd); - - if(!cac_Connect(hnd, NULL)) { - fprintf(stderr, "Could not connect to server %s. Error: %s\n", hnd->server, nt_errstr(hnd->status)); - exit(-1); - } - - /*open a handle to the scm*/ - ZERO_STRUCT(sos); - - sos.in.access = SC_MANAGER_ALL_ACCESS; - - if(!cac_SvcOpenScm(hnd, mem_ctx, &sos)) { - fprintf(stderr, "Could not open SCM. Error: %s\n", nt_errstr(hnd->status)); - goto done; - } - - printf("Opened SCM\n"); - - tmp[0] = 0x00; - while(tmp[0] != 'q') { - printf("\n"); - printf("[e] Enum Services\n"); - printf("[o] Open Service\n"); - printf("[x] Close Service\n"); - printf("[g] Get service status\n"); - printf("[s] Start service\n"); - printf("[t] Stop service\n"); - printf("[p] Pause service\n"); - printf("[r] Resume service\n"); - printf("[c] Get service config\n"); - - printf("[d] Get display name\n"); - - printf("[q]uit\n\n"); - printf("Enter option: "); - cactest_readline(stdin, tmp); - - printf("\n"); - - switch(tmp[0]) { - case 'e': /*enum services*/ - ZERO_STRUCT(es); - es.in.scm_hnd = sos.out.scm_hnd; - - if(!cac_SvcEnumServices(hnd, mem_ctx, &es)) { - printf("Could not enumerate services. Error: %s\n", nt_errstr(hnd->status)); - break; - } - - for(i = 0; i < es.out.num_services; i++) { - print_cac_service(es.out.services[i]); - } - printf("Enumerated %d services:\n", es.out.num_services); - - break; - - case 'o': /*Open service*/ - ZERO_STRUCT(os); - - printf("Enter service name: "); - cactest_readline(stdin, tmp); - - os.in.name = talloc_strdup(mem_ctx, tmp); - os.in.scm_hnd = sos.out.scm_hnd; - os.in.access = SERVICE_ALL_ACCESS; - - if(!cac_SvcOpenService(hnd, mem_ctx, &os)) { - printf("Could not open service. Error: %s\n", nt_errstr(hnd->status)); - break; - } - - printf("Opened service.\n"); - svc_hnd = os.out.svc_hnd; - - break; - case 'x': /*close service*/ - if(!svc_hnd) { - printf("Must open service first!\n"); - break; - } - - cac_SvcClose(hnd, mem_ctx, svc_hnd); - svc_hnd = NULL; - break; - case 'g': /*get svc status*/ - - if(!svc_hnd) { - printf("Must open service first!\n"); - break; - } - - ZERO_STRUCT(gs); - - gs.in.svc_hnd = svc_hnd; - - if(!cac_SvcGetStatus(hnd, mem_ctx, &gs)) { - printf("Could not get status. Error: %s\n", nt_errstr(hnd->status)); - break; - } - - print_service_status(gs.out.status); - break; - case 's': /*start service*/ - if(!svc_hnd) { - printf("Must open service first!\n"); - break; - } - - ZERO_STRUCT(start); - - start.in.svc_hnd = svc_hnd; - - printf("Enter number of parameters: "); - scanf("%d", &start.in.num_parms); - - start.in.parms = talloc_array(mem_ctx, char *, start.in.num_parms); - - for(i = 0; i < start.in.num_parms; i++) { - printf("Parm %d: ", i); - cactest_readline(stdin, tmp); - start.in.parms[i] = talloc_strdup(mem_ctx, tmp); - } - - printf("Timeout (seconds): "); - scanf("%d", &start.in.timeout); - - if(!cac_SvcStartService(hnd, mem_ctx, &start)) { - printf("Could not start service. Error: %s\n", nt_errstr(hnd->status)); - } - else { - printf("Started service.\n"); - } - - break; - case 't': /*stop service*/ - if(!svc_hnd) { - printf("Must open service first!\n"); - break; - } - - ZERO_STRUCT(stop); - stop.in.svc_hnd = svc_hnd; - - printf("Timeout (seconds): "); - scanf("%d", &stop.in.timeout); - - if(!cac_SvcStopService(hnd, mem_ctx, &stop)) { - if(CAC_OP_FAILED(hnd->status)) { - printf("Error occured: %s\n", nt_errstr(hnd->status)); - } - else { - printf("Service was not stopped within %d seconds.\n", stop.in.timeout); - print_service_status(stop.out.status); - } - } - else { - printf("Done.\n"); - print_service_status(stop.out.status); - } - break; - case 'd': /*get display name*/ - if(!svc_hnd) { - printf("Must open service first!\n"); - break; - } - - ZERO_STRUCT(gdn); - gdn.in.svc_hnd = svc_hnd; - - if(!cac_SvcGetDisplayName(hnd, mem_ctx, &gdn)) { - printf("Could not get display name. Error: %s\n", nt_errstr(hnd->status)); - } - else { - printf("\tDisplay Name: %s\n", gdn.out.display_name); - } - break; - - case 'p': /*pause service*/ - if(!svc_hnd) { - printf("Must open service first!\n"); - break; - } - - ZERO_STRUCT(pause); - pause.in.svc_hnd = svc_hnd; - - printf("Timeout (seconds): "); - scanf("%d", &pause.in.timeout); - - if(!cac_SvcPauseService(hnd, mem_ctx, &pause)) { - if(CAC_OP_FAILED(hnd->status)) { - printf("Error occured: %s\n", nt_errstr(hnd->status)); - } - else { - printf("Service was not paused within %d seconds.\n", pause.in.timeout); - print_service_status(pause.out.status); - } - } - else { - printf("Done.\n"); - print_service_status(pause.out.status); - } - - break; - - case 'r': /*resume service*/ - if(!svc_hnd) { - printf("Must open service first!\n"); - break; - } - - ZERO_STRUCT(res); - res.in.svc_hnd = svc_hnd; - - printf("Timeout (seconds): "); - scanf("%d", &res.in.timeout); - - if(!cac_SvcContinueService(hnd, mem_ctx, &res)) { - if(CAC_OP_FAILED(hnd->status)) { - printf("Error occured: %s\n", nt_errstr(hnd->status)); - } - else { - printf("Service was not resumed within %d seconds.\n", res.in.timeout); - print_service_status(res.out.status); - } - } - else { - printf("Done.\n"); - print_service_status(res.out.status); - } - - break; - - case 'c': /*get service config*/ - if(!svc_hnd) { - printf("Must open service first!\n"); - break; - } - - ZERO_STRUCT(sgc); - - sgc.in.svc_hnd = svc_hnd; - - if(!cac_SvcGetServiceConfig(hnd, mem_ctx, &sgc)) { - printf("Could not get service config. Error: %s\n", nt_errstr(hnd->status)); - } - else { - print_service_config(&sgc.out.config); - } - break; - - case 'q': /*quit*/ - break; - default: - printf("Invalid command\n"); - } - } - - cac_SvcClose(hnd, mem_ctx, sos.out.scm_hnd); - - done: - cac_FreeHandle(hnd); - - talloc_destroy(mem_ctx); - - return 0; -} - diff --git a/examples/libmsrpc/test/test_util.c b/examples/libmsrpc/test/test_util.c deleted file mode 100644 index 81a9c9203d..0000000000 --- a/examples/libmsrpc/test/test_util.c +++ /dev/null @@ -1,408 +0,0 @@ -/*some utility functions for the registry tests*/ - -#include "libmsrpc.h" -#include "test_util.h" - - -void cactest_print_usage(char **argv) { - printf("Usage:\n"); - printf(" %s server [-U username] [-W domain] [-P passwprd] [-N netbios_name]\n", argv[0]); -} - -/*allocates memory for auth info and parses domain/user/server out of command line*/ -void cac_parse_cmd_line(int argc, char **argv, CacServerHandle *hnd) { - int i = 0; - - ZERO_STRUCTP(hnd->username); - ZERO_STRUCTP(hnd->domain); - ZERO_STRUCTP(hnd->netbios_name); - ZERO_STRUCTP(hnd->password); - - for(i = 1; i < argc; i++) { - if( strncmp(argv[i], "-U", sizeof(fstring)) == 0) { - strncpy(hnd->username, argv[i+1], sizeof(fstring)); - i++; - } - - else if(strncmp(argv[i], "-W", sizeof(fstring)) == 0) { - strncpy(hnd->domain, argv[i+1], sizeof(fstring)); - i++; - - } - - else if(strncmp(argv[i], "-P", sizeof(fstring)) == 0) { - strncpy(hnd->password, argv[i+1], sizeof(fstring)); - i++; - - } - - else if(strncmp(argv[i], "-N", sizeof(fstring)) == 0) { - strncpy(hnd->netbios_name, argv[i+1], sizeof(fstring)); - i++; - } - - else if(strncmp(argv[i], "-d", sizeof(fstring)) == 0) { - sscanf(argv[i+1], "%d", &hnd->debug); - i++; - } - - else { /*assume this is the server name*/ - strncpy(hnd->server, argv[i], sizeof(fstring)); - } - } - - if(!hnd->server) { - cactest_print_usage(argv); - cac_FreeHandle(hnd); - exit(-1); - } - -} - -void print_value(uint32 type, REG_VALUE_DATA *data) { - int i = 0; - - switch(type) { - case REG_SZ: - printf(" Type: REG_SZ\n"); - printf(" Value: %s\n", data->reg_sz); - break; - case REG_EXPAND_SZ: - printf(" Type: REG_EXPAND_SZ\n"); - printf(" Value: %s\n", data->reg_expand_sz); - break; - case REG_MULTI_SZ: - printf(" Type: REG_MULTI_SZ\n"); - printf(" Values: "); - - for(i = 0; i < data->reg_multi_sz.num_strings; i++) { - printf(" %d: %s\n", i, data->reg_multi_sz.strings[i]); - } - break; - case REG_DWORD: - printf(" Type: REG_DWORD\n"); - printf(" Value: %d\n", data->reg_dword); - break; - case REG_DWORD_BE: - printf(" Type: REG_DWORD_BE\n"); - printf(" Value: 0x%x\n", data->reg_dword_be); - break; - case REG_BINARY: - printf(" Type: REG_BINARY\n"); - break; - default: - printf(" Invalid type: %d\n", type); - - } - - printf("\n"); - -} - -void cactest_readline(FILE *in, fstring line) { - - int c; - - c = fgetc(in); - if(c != '\n') - ungetc(c, in); - - fgets(line, sizeof(fstring), in); - - if(line[strlen(line) - 1] == '\n') - line[strlen(line) - 1] = '\0'; - -} - -void cactest_GetAuthDataFn(const char * pServer, - const char * pShare, - char * pWorkgroup, - int maxLenWorkgroup, - char * pUsername, - int maxLenUsername, - char * pPassword, - int maxLenPassword) - -{ - char temp[sizeof(fstring)]; - - static char authUsername[sizeof(fstring)]; - static char authWorkgroup[sizeof(fstring)]; - static char authPassword[sizeof(fstring)]; - static char authSet = 0; - - char *pass = NULL; - - if (authSet) - { - strncpy(pWorkgroup, authWorkgroup, maxLenWorkgroup - 1); - strncpy(pUsername, authUsername, maxLenUsername - 1); - strncpy(pPassword, authPassword, maxLenPassword - 1); - } - else - { - if(pWorkgroup[0] != '\0') { - strncpy(authWorkgroup, pWorkgroup, maxLenWorkgroup - 1); - } - else { - d_printf("Domain: [%s] ", pWorkgroup); - fscanf(stdin, "%s", temp); - - if (temp[0] != '\0') - { - strncpy(pWorkgroup, temp, maxLenWorkgroup - 1); - strncpy(authWorkgroup, temp, maxLenWorkgroup - 1); - } - } - - - if(pUsername[0] != '\0') { - strncpy(authUsername, pUsername, maxLenUsername - 1); - } - else { - d_printf("Username: [%s] ", pUsername); - fscanf(stdin, "%s", temp); - - if (temp[strlen(temp) - 1] == '\n') /* A new line? */ - { - temp[strlen(temp) - 1] = '\0'; - } - - if (temp[0] != '\0') - { - strncpy(pUsername, temp, maxLenUsername - 1); - strncpy(authUsername, pUsername, maxLenUsername - 1); - } - } - if(pPassword[0] != '\0') { - strncpy(authPassword, pPassword, maxLenPassword - 1); - } - else { - pass = getpass("Password: "); - if (pass) - fstrcpy(temp, pass); - if (temp[strlen(temp) - 1] == '\n') /* A new line? */ - { - temp[strlen(temp) - 1] = '\0'; - } - if (temp[0] != '\0') - { - strncpy(pPassword, temp, maxLenPassword - 1); - strncpy(authPassword, pPassword, maxLenPassword - 1); - } - } - authSet = 1; - } -} - -void cactest_reg_input_val(TALLOC_CTX *mem_ctx, int *type, char **name, REG_VALUE_DATA *data) { - fstring tmp; - int i; - - printf("Enter value name: \n"); - cactest_readline(stdin, tmp); - *name = talloc_strdup(mem_ctx, tmp); - - do { - printf("Enter type. %d = REG_SZ, %d = REG_DWORD, %d = REG_MULTI_SZ: ", REG_SZ, REG_DWORD, REG_MULTI_SZ); - scanf("%d", type); - } while(*type != REG_SZ && *type != REG_DWORD && *type != REG_MULTI_SZ); - - switch(*type) { - case REG_SZ: - printf("Enter string:\n"); - cactest_readline(stdin, tmp); - - data->reg_sz = talloc_strdup(mem_ctx, tmp); - break; - - case REG_DWORD: - printf("Enter dword: "); - scanf("%d", &data->reg_dword); - break; - - case REG_MULTI_SZ: - printf("Enter number of strings: "); - scanf("%d", &data->reg_multi_sz.num_strings); - - data->reg_multi_sz.strings = talloc_array(mem_ctx, char *, data->reg_multi_sz.num_strings); - - for(i = 0; i < data->reg_multi_sz.num_strings; i++) { - printf("String %d: ", i+1); - cactest_readline(stdin, tmp); - - data->reg_multi_sz.strings[i] = talloc_strdup(mem_ctx, tmp); - } - break; - } -} - -void print_cac_user_info(CacUserInfo *info) { - printf(" User Name : %s\n", info->username); - printf(" Full Name : %s\n", info->full_name); - printf(" Home Dir : %s\n", info->home_dir); - printf(" Home Drive : %s\n", info->home_drive); - printf(" Profile Path : %s\n", info->profile_path); - printf(" Logon Script : %s\n", info->logon_script); - printf(" Description : %s\n", info->description); - printf(" Workstations : %s\n", info->workstations); - printf(" Remote Dial : %s\n", info->dial); - - printf(" Logon Time : %s\n", http_timestring(info->logon_time)); - printf(" Logoff Time : %s\n", http_timestring(info->logoff_time)); - printf(" Kickoff Time : %s\n", http_timestring(info->kickoff_time)); - printf(" Pass last set: %s\n", http_timestring(info->pass_last_set_time)); - printf(" Pass can set : %s\n", http_timestring(info->pass_can_change_time)); - printf(" Pass must set: %s\n", http_timestring(info->pass_must_change_time)); - - printf(" User RID : 0x%x\n", info->rid); - printf(" Group RID : 0x%x\n", info->group_rid); - printf(" ACB Mask : 0x%x\n", info->acb_mask); - - printf(" Bad pwd count: %d\n", info->bad_passwd_count); - printf(" Logon Cuont : %d\n", info->logon_count); - - printf(" NT Password : %s\n", info->nt_password); - printf(" LM Password : %s\n", info->lm_password); - -} - -void edit_readline(fstring line) { - fgets(line, sizeof(fstring), stdin); - - if(line[strlen(line)-1] == '\n') - line[strlen(line)-1] = '\0'; -} -void edit_cac_user_info(TALLOC_CTX *mem_ctx, CacUserInfo *info) { - fstring tmp; - - printf(" User Name [%s]: ", info->username); - edit_readline(tmp); - - if(tmp[0] != '\0') - info->username = talloc_strdup(mem_ctx, tmp); - - printf(" Full Name [%s]: ", info->full_name); - - edit_readline(tmp); - if(tmp[0] != '\0') - info->full_name = talloc_strdup(mem_ctx, tmp); - - printf(" Description [%s]: ", info->description); - edit_readline(tmp); - if(tmp[0] != '\0') - info->description = talloc_strdup(mem_ctx, tmp); - - printf(" Remote Dial [%s]: ", info->dial); - edit_readline(tmp); - if(tmp[0] != '\0') - info->dial = talloc_strdup(mem_ctx, tmp); - - printf(" ACB Mask [0x%x]: ", info->acb_mask); - edit_readline(tmp); - if(tmp[0] != '\0') - sscanf(tmp, "%x", &info->acb_mask); - - printf(" Must change pass at next logon? [y/N]: "); - edit_readline(tmp); - - if(tmp[0] == 'y' || tmp[0] == 'Y') - info->pass_must_change= True; - -} - -void print_cac_group_info(CacGroupInfo *info) { - printf(" Group Name : %s\n", info->name); - printf(" Description : %s\n", info->description); - printf(" Num Members : %d\n", info->num_members); -} - -void edit_cac_group_info(TALLOC_CTX *mem_ctx, CacGroupInfo *info) { - fstring tmp; - - printf("Group Name [%s]: ", info->name); - edit_readline(tmp); - if(tmp[0] != '\0') - info->name = talloc_strdup(mem_ctx, tmp); - - printf("Description [%s]: ", info->description); - edit_readline(tmp); - if(tmp[0] != '\0') - info->description = talloc_strdup(mem_ctx, tmp); -} - -char *srv_role_str(uint32 role) { - switch(role) { - case ROLE_STANDALONE: - return "STANDALONE"; - break; - case ROLE_DOMAIN_MEMBER: - return "DOMAIN_MEMBER"; - break; - case ROLE_DOMAIN_BDC: - return "DOMAIN_BDC"; - break; - case ROLE_DOMAIN_PDC: - return "DOMAIN_PDC"; - break; - } - - return "Invalid role!\n"; -} - -char *cactime_str(CacTime ctime, fstring tmp) { - - snprintf(tmp, sizeof(fstring), "%u Days, %u Hours, %u Minutes, %u Seconds", ctime.days, ctime.hours, ctime.minutes, ctime.seconds); - - return tmp; -} - -void print_cac_domain_info(CacDomainInfo *info) { - fstring tmp; - - printf(" Server Role : %s\n", srv_role_str(info->server_role)); - printf(" Num Users : %d\n", info->num_users); - printf(" Num Domain Groups: %d\n", info->num_domain_groups); - printf(" Num Local Groups : %d\n", info->num_local_groups); - printf(" Comment : %s\n", info->comment); - printf(" Domain Name : %s\n", info->domain_name); - printf(" Server Name : %s\n", info->server_name); - printf(" Min. Pass. Length: %d\n", info->min_pass_length); - printf(" Password History : %d\n", info->pass_history); - printf("\n"); - printf(" Passwords Expire In : %s\n", cactime_str(info->expire, tmp)); - printf(" Passwords Can Change in: %s\n", cactime_str(info->min_pass_age, tmp)); - printf(" Lockouts last : %s\n", cactime_str(info->lockout_duration, tmp)); - printf(" Allowed Bad Attempts : %d\n", info->num_bad_attempts); -} - -void print_cac_service(CacService svc) { - printf("\tService Name: %s\n", svc.service_name); - printf("\tDisplay Name: %s\n", svc.display_name); - print_service_status(svc.status); -} - -void print_service_status(SERVICE_STATUS status) { - printf("\tStatus:\n"); - printf("\t Type: 0x%x\n", status.type); - printf("\t State: 0x%x\n", status.state); - printf("\t Controls: 0x%x\n", status.controls_accepted); - printf("\t W32 Exit Code: 0x%x\n", status.win32_exit_code); - printf("\t SVC Exit Code: 0x%x\n", status.service_exit_code); - printf("\t Checkpoint: 0x%x\n", status.check_point); - printf("\t Wait Hint: 0x%x\n", status.wait_hint); - printf("\n"); -} - -void print_service_config(CacServiceConfig *config) { - printf("\tConfig:\n"); - printf("\tType: 0x%x\n", config->type); - printf("\tStart Type: 0x%x\n", config->start_type); - printf("\tError config: 0x%x\n", config->error_control); - printf("\tExecutable Path: %s\n", config->exe_path); - printf("\tLoad Order Group: %s\n", config->load_order_group); - printf("\tTag ID: 0x%x\n", config->tag_id); - printf("\tDependencies: %s\n", config->dependencies); - printf("\tStart Name: %s\n", config->start_name); - printf("\tDisplay Name: %s\n", config->display_name); -} diff --git a/examples/libmsrpc/test/test_util.h b/examples/libmsrpc/test/test_util.h deleted file mode 100644 index 9b27599da1..0000000000 --- a/examples/libmsrpc/test/test_util.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef TEST_UTIL_H -#define TEST_UTIL_H - -#include "libmsrpc.h" - -/*prototypes*/ -void cactest_GetAuthDataFn(const char * pServer, - const char * pShare, - char * pWorkgroup, - int maxLenWorkgroup, - char * pUsername, - int maxLenUsername, - char * pPassword, - int maxLenPassword); - - -void cactest_print_usage(char **argv); -void cac_parse_cmd_line(int argc, char **argv, CacServerHandle *hnd); -void print_value(uint32 type, REG_VALUE_DATA *data); -void cactest_readline(FILE *in, fstring line); -void cactest_reg_input_val(TALLOC_CTX *mem_ctx, int *type, char **name, REG_VALUE_DATA *data); -void print_cac_user_info(CacUserInfo *info); -void edit_cac_user_info(TALLOC_CTX *mem_ctx, CacUserInfo *info); -void print_cac_group_info(CacGroupInfo *info); -void edit_cac_group_info(TALLOC_CTX *mem_ctx, CacGroupInfo *info); -void print_cac_domain_info(CacDomainInfo *info); -void print_cac_service(CacService svc); -void print_service_status(SERVICE_STATUS status); -void print_service_config(CacServiceConfig *config); - -#endif /*TEST_UTIL_H*/ diff --git a/examples/libsmbclient/Makefile b/examples/libsmbclient/Makefile index be383aea67..a50e80a918 100644 --- a/examples/libsmbclient/Makefile +++ b/examples/libsmbclient/Makefile @@ -1,30 +1,34 @@ # CC = gcc -SAMBA_INCL = ../../source/include +SAMBA_INCL = -I/usr/local/samba/include EXTLIB_INCL = -I/usr/include/gtk-1.2 \ -I/usr/include/glib-1.2 \ -I/usr/lib/glib/include - +EXTLIB_INCL = `gtk-config --cflags` DEFS = -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -CFLAGS = -O0 -g -I$(SAMBA_INCL) $(EXTLIB_INCL) $(DEFS) +CFLAGS = -O0 -g $(SAMBA_INCL) $(EXTLIB_INCL) $(DEFS) LDFLAGS = -L/usr/local/samba/lib \ -lldap -lkrb5 -lgssapi_krb5 #LIBSMBCLIENT = /usr/local/samba/lib/libsmbclient.so -LIBSMBCLIENT = ../../source/bin/libsmbclient.a -ldl -lresolv +LIBSMBCLIENT = -lwbclient -lsmbclient -ldl -lresolv TESTS= testsmbc \ testacl \ testacl2 \ + testacl3 \ testbrowse \ testbrowse2 \ teststat \ teststat2 \ + teststat3 \ + testtruncate \ testchmod \ testutime \ - testread + testread \ + testwrite # tree \ @@ -46,6 +50,10 @@ testacl2: testacl2.o @echo Linking testacl2 $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBSMBCLIENT) -lpopt +testacl3: testacl3.o + @echo Linking testacl3 + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBSMBCLIENT) -lpopt + testbrowse: testbrowse.o @echo Linking testbrowse $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBSMBCLIENT) -lpopt @@ -62,6 +70,14 @@ teststat2: teststat2.o @echo Linking teststat2 $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBSMBCLIENT) -lpopt +teststat3: teststat3.o + @echo Linking teststat3 + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBSMBCLIENT) -lpopt + +testtruncate: testtruncate.o + @echo Linking testtruncate + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBSMBCLIENT) -lpopt + testchmod: testchmod.o @echo Linking testchmod $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBSMBCLIENT) -lpopt @@ -74,6 +90,10 @@ testread: testread.o @echo Linking testread $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBSMBCLIENT) -lpopt +testwrite: testwrite.o + @echo Linking testwrite + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBSMBCLIENT) -lpopt + smbsh: make -C smbwrapper diff --git a/examples/libsmbclient/get_auth_data_fn.h b/examples/libsmbclient/get_auth_data_fn.h index eb493885af..6b91c97337 100644 --- a/examples/libsmbclient/get_auth_data_fn.h +++ b/examples/libsmbclient/get_auth_data_fn.h @@ -1,3 +1,5 @@ +#include <stdlib.h> + static void get_auth_data_fn(const char * pServer, const char * pShare, @@ -8,8 +10,31 @@ get_auth_data_fn(const char * pServer, char * pPassword, int maxLenPassword) { - char temp[128]; - + char temp[128]; + char server[256] = { '\0' }; + char share[256] = { '\0' }; + char workgroup[256] = { '\0' }; + char username[256] = { '\0' }; + char password[256] = { '\0' }; + + static int krb5_set = 1; + + if (strcmp(server, pServer) == 0 && + strcmp(share, pShare) == 0 && + *workgroup != '\0' && + *username != '\0') + { + strncpy(pWorkgroup, workgroup, maxLenWorkgroup - 1); + strncpy(pUsername, username, maxLenUsername - 1); + strncpy(pPassword, password, maxLenPassword - 1); + return; + } + + if (krb5_set && getenv("KRB5CCNAME")) { + krb5_set = 0; + return; + } + fprintf(stdout, "Workgroup: [%s] ", pWorkgroup); fgets(temp, sizeof(temp), stdin); @@ -48,4 +73,10 @@ get_auth_data_fn(const char * pServer, { strncpy(pPassword, temp, maxLenPassword - 1); } + + strncpy(workgroup, pWorkgroup, sizeof(workgroup) - 1); + strncpy(username, pUsername, sizeof(username) - 1); + strncpy(password, pPassword, sizeof(password) - 1); + + krb5_set = 1; } diff --git a/examples/libsmbclient/smbwrapper/Makefile b/examples/libsmbclient/smbwrapper/Makefile index c94ef8fa6a..726435319f 100644 --- a/examples/libsmbclient/smbwrapper/Makefile +++ b/examples/libsmbclient/smbwrapper/Makefile @@ -1,4 +1,4 @@ -LIBS = -lsmbclient -ldl +LIBS = -lwbclient -lsmbclient -ldl DEFS = -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE CFLAGS = -I$(SAMBA_INCL) $(EXTLIB_INCL) diff --git a/examples/libsmbclient/smbwrapper/select.c b/examples/libsmbclient/smbwrapper/select.c index aa90169ee7..bb7a25f13e 100644 --- a/examples/libsmbclient/smbwrapper/select.c +++ b/examples/libsmbclient/smbwrapper/select.c @@ -7,7 +7,7 @@ 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 + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -16,8 +16,7 @@ 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. + along with this program. If not, see <http://www.gnu.org/licenses/>. */ /* @@ -73,13 +72,12 @@ int sys_select_intr(int maxfd, fd_set *readfds, fd_set *writefds, fd_set *errorf int ret; fd_set *readfds2, readfds_buf, *writefds2, writefds_buf, *errorfds2, errorfds_buf; struct timeval tval2, *ptval, end_time, now_time; - extern void GetTimeOfDay(struct timeval *tval); readfds2 = (readfds ? &readfds_buf : NULL); writefds2 = (writefds ? &writefds_buf : NULL); errorfds2 = (errorfds ? &errorfds_buf : NULL); if (tval) { - GetTimeOfDay(&end_time); + gettimeofday(&end_time, NULL); end_time.tv_sec += tval->tv_sec; end_time.tv_usec += tval->tv_usec; end_time.tv_sec += end_time.tv_usec / 1000000; @@ -97,7 +95,7 @@ int sys_select_intr(int maxfd, fd_set *readfds, fd_set *writefds, fd_set *errorf if (errorfds) errorfds_buf = *errorfds; if (tval) { - GetTimeOfDay(&now_time); + gettimeofday(&now_time, NULL); tval2.tv_sec = end_time.tv_sec - now_time.tv_sec; tval2.tv_usec = end_time.tv_usec - now_time.tv_usec; if ((signed long) tval2.tv_usec < 0) { diff --git a/examples/libsmbclient/smbwrapper/smbsh.1.xml b/examples/libsmbclient/smbwrapper/smbsh.1.xml index 7424eb9605..5494f351c3 100644 --- a/examples/libsmbclient/smbwrapper/smbsh.1.xml +++ b/examples/libsmbclient/smbwrapper/smbsh.1.xml @@ -7,7 +7,7 @@ <manvolnum>1</manvolnum> <refmiscinfo class="source">Samba</refmiscinfo> <refmiscinfo class="manual">User Commands</refmiscinfo> - <refmiscinfo class="version">3.0</refmiscinfo> + <refmiscinfo class="version">3.2</refmiscinfo> </refmeta> @@ -118,7 +118,7 @@ <refsect1> <title>VERSION</title> - <para>This man page is correct for version 3.0 of the Samba suite.</para> + <para>This man page is correct for version 3 of the Samba suite.</para> </refsect1> <refsect1> diff --git a/examples/libsmbclient/smbwrapper/smbsh.c b/examples/libsmbclient/smbwrapper/smbsh.c index 23b1ac26c7..f2b5bf49fb 100644 --- a/examples/libsmbclient/smbwrapper/smbsh.c +++ b/examples/libsmbclient/smbwrapper/smbsh.c @@ -7,7 +7,7 @@ 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 + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -16,8 +16,7 @@ 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. + along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <sys/types.h> diff --git a/examples/libsmbclient/smbwrapper/smbw.c b/examples/libsmbclient/smbwrapper/smbw.c index a44f2f4046..e2e44c1f0f 100644 --- a/examples/libsmbclient/smbwrapper/smbw.c +++ b/examples/libsmbclient/smbwrapper/smbw.c @@ -7,7 +7,7 @@ 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 + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -16,8 +16,7 @@ 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. + along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <stdio.h> @@ -175,11 +174,11 @@ static void do_init(StartupType startupType) exit(1); } - smbw_ctx->debug = debug_level; - smbw_ctx->callbacks.auth_fn = get_auth_data_fn; - smbw_ctx->options.browse_max_lmb_count = 0; - smbw_ctx->options.urlencode_readdir_entries = 1; - smbw_ctx->options.one_share_per_server = 1; + smbc_setDebug(smbw_ctx, debug_level); + smbc_setFunctionAuthData(smbw_ctx, get_auth_data_fn); + smbc_setOptionBrowseMaxLmbCount(smbw_ctx, 0); + smbc_setOptionUrlEncodeReaddirEntries(smbw_ctx, 1); + smbc_setOptionOneSharePerServer(smbw_ctx, 1); if (smbc_init_context(smbw_ctx) == NULL) { fprintf(stderr, "Could not initialize context.\n"); diff --git a/examples/libsmbclient/smbwrapper/smbw.h b/examples/libsmbclient/smbwrapper/smbw.h index 161d57ebbb..8bf1809ec9 100644 --- a/examples/libsmbclient/smbwrapper/smbw.h +++ b/examples/libsmbclient/smbwrapper/smbw.h @@ -7,7 +7,7 @@ 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 + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -16,8 +16,7 @@ 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. + along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef _SMBW_H diff --git a/examples/libsmbclient/smbwrapper/smbw_dir.c b/examples/libsmbclient/smbwrapper/smbw_dir.c index 986b7f8220..6e473bf0a3 100644 --- a/examples/libsmbclient/smbwrapper/smbw_dir.c +++ b/examples/libsmbclient/smbwrapper/smbw_dir.c @@ -7,7 +7,7 @@ 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 + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -16,8 +16,7 @@ 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. + along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "smbw.h" diff --git a/examples/libsmbclient/smbwrapper/smbw_stat.c b/examples/libsmbclient/smbwrapper/smbw_stat.c index a386c09209..7b2b011282 100644 --- a/examples/libsmbclient/smbwrapper/smbw_stat.c +++ b/examples/libsmbclient/smbwrapper/smbw_stat.c @@ -7,7 +7,7 @@ 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 + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -16,8 +16,7 @@ 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. + along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "smbw.h" diff --git a/examples/libsmbclient/smbwrapper/wrapper.c b/examples/libsmbclient/smbwrapper/wrapper.c index e6f764c16d..958e00636e 100644 --- a/examples/libsmbclient/smbwrapper/wrapper.c +++ b/examples/libsmbclient/smbwrapper/wrapper.c @@ -7,7 +7,7 @@ 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 + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -16,8 +16,7 @@ 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. + along with this program. If not, see <http://www.gnu.org/licenses/>. */ /* @@ -62,6 +61,7 @@ #include <dirent.h> #include <signal.h> #include <stdarg.h> +#include <string.h> #ifdef __USE_GNU # define SMBW_USE_GNU #endif diff --git a/examples/libsmbclient/smbwrapper/wrapper.h b/examples/libsmbclient/smbwrapper/wrapper.h index 5a18b9d76c..e83bb1ee5d 100644 --- a/examples/libsmbclient/smbwrapper/wrapper.h +++ b/examples/libsmbclient/smbwrapper/wrapper.h @@ -6,7 +6,7 @@ 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 + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -15,8 +15,7 @@ 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. + along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef __WRAPPER_H__ diff --git a/examples/libsmbclient/testacl.c b/examples/libsmbclient/testacl.c index 4d327b39a7..00e1c2c9da 100644 --- a/examples/libsmbclient/testacl.c +++ b/examples/libsmbclient/testacl.c @@ -7,6 +7,7 @@ enum acl_mode { + SMB_ACL_LIST, SMB_ACL_GET, SMB_ACL_SET, SMB_ACL_DELETE, @@ -24,7 +25,7 @@ int main(int argc, const char *argv[]) int debug = 0; int numeric = 0; int full_time_names = 0; - enum acl_mode mode = SMB_ACL_GET; + enum acl_mode mode = SMB_ACL_LIST; static char *the_acl = NULL; int ret; char *p; @@ -142,13 +143,37 @@ int main(int argc, const char *argv[]) if (full_time_names) { SMBCCTX *context = smbc_set_context(NULL); - smbc_option_set(context, "full_time_names", 1); + smbc_setOptionFullTimeNames(context, 1); } /* Perform requested action */ switch(mode) { + case SMB_ACL_LIST: + ret = smbc_listxattr(path, value, sizeof(value)-2); + if (ret < 0) + { + printf("Could not get attribute list for [%s] %d: %s\n", + path, errno, strerror(errno)); + return 1; + } + + /* + * The list of attributes has a series of null-terminated strings. + * The list of strings terminates with an extra null byte, thus two in + * a row. Ensure that our buffer, which is conceivably shorter than + * the list of attributes, actually ends with two null bytes in a row. + */ + value[sizeof(value) - 2] = '\0'; + value[sizeof(value) - 1] = '\0'; + printf("Supported attributes:\n"); + for (p = value; *p; p += strlen(p) + 1) + { + printf("\t%s\n", p); + } + break; + case SMB_ACL_GET: if (the_acl == NULL) { diff --git a/examples/libsmbclient/testacl2.c b/examples/libsmbclient/testacl2.c index df38fe208e..d2a97cf2d2 100644 --- a/examples/libsmbclient/testacl2.c +++ b/examples/libsmbclient/testacl2.c @@ -39,7 +39,7 @@ int main(int argc, const char *argv[]) } SMBCCTX *context = smbc_set_context(NULL); - smbc_option_set(context, "full_time_names", 1); + smbc_setOptionFullTimeNames(context, 1); the_acl = strdup("system.nt_sec_desc.*"); ret = smbc_getxattr(argv[1], the_acl, value, sizeof(value)); diff --git a/examples/libsmbclient/testacl3.c b/examples/libsmbclient/testacl3.c new file mode 100644 index 0000000000..4ef6e80a7b --- /dev/null +++ b/examples/libsmbclient/testacl3.c @@ -0,0 +1,62 @@ +#include <sys/types.h> +#include <stdio.h> +#include <unistd.h> +#include <string.h> +#include <time.h> +#include <errno.h> +#include <libsmbclient.h> +#include "get_auth_data_fn.h" + + +int main(int argc, char * argv[]) +{ + int i; + int fd; + int ret; + int debug = 0; + int mode = 0666; + int savedErrno; + char value[2048]; + char path[2048]; + char * the_acl; + char * p; + time_t t0; + time_t t1; + struct stat st; + SMBCCTX * context; + + smbc_init(get_auth_data_fn, debug); + + context = smbc_set_context(NULL); + smbc_setOptionFullTimeNames(context, 1); + + for (;;) + { + fprintf(stdout, "Path: "); + *path = '\0'; + fgets(path, sizeof(path) - 1, stdin); + if (strlen(path) == 0) + { + return 0; + } + + p = path + strlen(path) - 1; + if (*p == '\n') + { + *p = '\0'; + } + + the_acl = strdup("system.nt_sec_desc.*+"); + ret = smbc_getxattr(path, the_acl, value, sizeof(value)); + if (ret < 0) + { + printf("Could not get attributes for [%s] %d: %s\n", + path, errno, strerror(errno)); + return 1; + } + + printf("Attributes for [%s] are:\n%s\n", path, value); + } + + return 0; +} diff --git a/examples/libsmbclient/testbrowse.c b/examples/libsmbclient/testbrowse.c index 562d2c2aeb..a6e6395078 100644 --- a/examples/libsmbclient/testbrowse.c +++ b/examples/libsmbclient/testbrowse.c @@ -108,24 +108,24 @@ main(int argc, char * argv[]) } /* Set mandatory options (is that a contradiction in terms?) */ - context->debug = debug; + smbc_setDebug(context, debug); if (context_auth) { - context->callbacks.auth_fn = NULL; - smbc_option_set(context, - "auth_function", - (void *) get_auth_data_with_context_fn); - smbc_option_set(context, "user_data", "hello world"); + smbc_setFunctionAuthDataWithContext(context, + get_auth_data_with_context_fn); + smbc_setOptionUserData(context, "hello world"); } else { - context->callbacks.auth_fn = - (no_auth ? no_auth_data_fn : get_auth_data_fn); + smbc_setFunctionAuthData(context, get_auth_data_fn); } + smbc_setOptionUseKerberos(context, 1); + smbc_setOptionFallbackAfterKerberos(context, 1); + /* If we've been asked to log to stderr instead of stdout, ... */ if (debug_stderr) { /* ... then set the option to do so */ - smbc_option_set(context, "debug_to_stderr", 1); + smbc_setOptionDebugToStderr(context, 1); } - + /* Initialize the context using the previously specified options */ if (!smbc_init_context(context)) { smbc_free_context(context, 0); @@ -199,7 +199,7 @@ get_auth_data_with_context_fn(SMBCCTX * context, { printf("Authenticating with context 0x%lx", context); if (context != NULL) { - char *user_data = smbc_option_get(context, "user_data"); + char *user_data = smbc_getOptionUserData(context); printf(" with user data %s", user_data); } printf("\n"); diff --git a/examples/libsmbclient/testbrowse2.c b/examples/libsmbclient/testbrowse2.c index 76d98b9602..0ac1d72bb4 100644 --- a/examples/libsmbclient/testbrowse2.c +++ b/examples/libsmbclient/testbrowse2.c @@ -93,8 +93,8 @@ SMBCCTX* create_smbctx(){ if ((ctx = smbc_new_context()) == NULL) return NULL; - ctx->debug = debuglevel; - ctx->callbacks.auth_fn = smbc_auth_fn; + smbc_setDebug(ctx, debuglevel); + smbc_setFunctionAuthData(ctx, smbc_auth_fn); if (smbc_init_context(ctx) == NULL){ smbc_free_context(ctx, 1); @@ -105,7 +105,7 @@ SMBCCTX* create_smbctx(){ } void delete_smbctx(SMBCCTX* ctx){ - ctx->callbacks.purge_cached_fn(ctx); + smbc_getFunctionPurgeCachedServers(ctx)(ctx); smbc_free_context(ctx, 1); } @@ -114,8 +114,9 @@ smbitem* get_smbitem_list(SMBCCTX *ctx, char *smb_path){ struct smbc_dirent *dirent; smbitem *list = NULL, *item; - if ((fd = ctx->opendir(ctx, smb_path)) == NULL) return NULL; - while((dirent = ctx->readdir(ctx, fd)) != NULL){ + if ((fd = smbc_getFunctionOpendir(ctx)(ctx, smb_path)) == NULL) + return NULL; + while((dirent = smbc_getFunctionReaddir(ctx)(ctx, fd)) != NULL){ if (strcmp(dirent->name, "") == 0) continue; if (strcmp(dirent->name, ".") == 0) continue; if (strcmp(dirent->name, "..") == 0) continue; @@ -128,7 +129,7 @@ smbitem* get_smbitem_list(SMBCCTX *ctx, char *smb_path){ strcpy(item->name, dirent->name); list = item; } - ctx->close_fn(ctx, fd); + smbc_getFunctionClose(ctx)(ctx, fd); return /* smbitem_list_sort */ (list); } @@ -167,7 +168,7 @@ void recurse(SMBCCTX *ctx, char *smb_group, char *smb_path, int maxlen){ delete_smbctx(ctx1); }else{ recurse(ctx, smb_group, smb_path, maxlen); - ctx->callbacks.purge_cached_fn(ctx); + smbc_getFunctionPurgeCachedServers(ctx)(ctx); } break; case SMBC_FILE_SHARE: @@ -181,7 +182,7 @@ void recurse(SMBCCTX *ctx, char *smb_group, char *smb_path, int maxlen){ if (list->type != SMBC_FILE){ recurse(ctx, smb_group, smb_path, maxlen); if (list->type == SMBC_FILE_SHARE) - ctx->callbacks.purge_cached_fn(ctx); + smbc_getFunctionPurgeCachedServers(ctx)(ctx); } break; } diff --git a/examples/libsmbclient/testread.c b/examples/libsmbclient/testread.c index d59fc70ec1..3f94884895 100644 --- a/examples/libsmbclient/testread.c +++ b/examples/libsmbclient/testread.c @@ -10,66 +10,58 @@ int main(int argc, char * argv[]) { + int i; int fd; int ret; int debug = 0; int mode = 0666; int savedErrno; char buffer[2048]; - char * pSmbPath = NULL; + char path[2048]; + char * p; time_t t0; time_t t1; struct stat st; - if (argc == 1) - { - pSmbPath = "smb://RANDOM/Public/bigfile"; - } - else if (argc == 2) - { - pSmbPath = argv[1]; - } - else - { - printf("usage: " - "%s [ smb://path/to/file ]\n", - argv[0]); - return 1; - } - smbc_init(get_auth_data_fn, debug); - printf("Open file %s\n", pSmbPath); - - t0 = time(NULL); - - if ((fd = smbc_open(pSmbPath, O_RDONLY, 0)) < 0) + for (;;) { - perror("smbc_open"); - return 1; - } + fprintf(stdout, "Path: "); + *path = '\0'; + fgets(path, sizeof(path) - 1, stdin); + if (strlen(path) == 0) + { + return 0; + } - printf("Beginning read loop.\n"); + p = path + strlen(path) - 1; + if (*p == '\n') + { + *p = '\0'; + } + + if ((fd = smbc_open(path, O_RDONLY, 0)) < 0) + { + perror("smbc_open"); + continue; + } - do - { - ret = smbc_read(fd, buffer, sizeof(buffer)); - savedErrno = errno; - if (ret > 0) fwrite(buffer, 1, ret, stdout); - } while (ret > 0); + do + { + ret = smbc_read(fd, buffer, sizeof(buffer)); + savedErrno = errno; + if (ret > 0) fwrite(buffer, 1, ret, stdout); + } while (ret > 0); - smbc_close(fd); + smbc_close(fd); - if (ret < 0) - { - errno = savedErrno; - perror("read"); - return 1; + if (ret < 0) + { + errno = savedErrno; + perror("read"); + } } - t1 = time(NULL); - - printf("Elapsed time: %d seconds\n", t1 - t0); - return 0; } diff --git a/examples/libsmbclient/testsmbc.c b/examples/libsmbclient/testsmbc.c index 45e67bee62..1f06437293 100644 --- a/examples/libsmbclient/testsmbc.c +++ b/examples/libsmbclient/testsmbc.c @@ -7,7 +7,7 @@ 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 + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -16,8 +16,7 @@ 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. + along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <stdio.h> @@ -26,7 +25,7 @@ #include <string.h> #include <unistd.h> #include <stdlib.h> -#include <libsmbclient.h> +#include "libsmbclient.h" #include "get_auth_data_fn.h" int global_id = 0; diff --git a/examples/libsmbclient/teststat3.c b/examples/libsmbclient/teststat3.c new file mode 100644 index 0000000000..26348b335c --- /dev/null +++ b/examples/libsmbclient/teststat3.c @@ -0,0 +1,78 @@ +#include <libsmbclient.h> +#include <sys/stat.h> +#include <string.h> +#include <stdio.h> +#include <time.h> +#include "get_auth_data_fn.h" + +/* + * This test is intended to ensure that the timestamps returned by + * libsmbclient using smbc_stat() are the same as those returned by + * smbc_fstat(). + */ + + +int main(int argc, char* argv[]) +{ + int fd; + struct stat st1; + struct stat st2; + char mtime[32]; + char ctime[32]; + char atime[32]; + char * pUrl = argv[1]; + + if(argc != 2) + { + printf("usage: %s <file_url>\n", argv[0]); + return 1; + } + + + smbc_init(get_auth_data_fn, 0); + + if (smbc_stat(pUrl, &st1) < 0) + { + perror("smbc_stat"); + return 1; + } + + if ((fd = smbc_open(pUrl, O_RDONLY, 0)) < 0) + { + perror("smbc_open"); + return 1; + } + + if (smbc_fstat(fd, &st2) < 0) + { + perror("smbc_fstat"); + return 1; + } + + smbc_close(fd); + +#define COMPARE(name, field) \ + if (st1.field != st2.field) \ + { \ + printf("Field " name " MISMATCH: st1=%lu, st2=%lu\n", \ + (unsigned long) st1.field, \ + (unsigned long) st2.field); \ + } + + COMPARE("st_dev", st_dev); + COMPARE("st_ino", st_ino); + COMPARE("st_mode", st_mode); + COMPARE("st_nlink", st_nlink); + COMPARE("st_uid", st_uid); + COMPARE("st_gid", st_gid); + COMPARE("st_rdev", st_rdev); + COMPARE("st_size", st_size); + COMPARE("st_blksize", st_blksize); + COMPARE("st_blocks", st_blocks); + COMPARE("st_atime", st_atime); + COMPARE("st_mtime", st_mtime); + COMPARE("st_ctime", st_ctime); + + return 0; +} + diff --git a/examples/libsmbclient/testtruncate.c b/examples/libsmbclient/testtruncate.c new file mode 100644 index 0000000000..8882acd85d --- /dev/null +++ b/examples/libsmbclient/testtruncate.c @@ -0,0 +1,82 @@ +#include <stdio.h> +#include <unistd.h> +#include <string.h> +#include <time.h> +#include <errno.h> +#include <libsmbclient.h> +#include "get_auth_data_fn.h" + + +int main(int argc, char * argv[]) +{ + int fd; + int ret; + int debug = 0; + int savedErrno; + char buffer[128]; + char * pSmbPath = NULL; + char * pLocalPath = NULL; + struct stat st; + + if (argc != 2) + { + printf("usage: " + "%s smb://path/to/file\n", + argv[0]); + return 1; + } + + smbc_init(get_auth_data_fn, debug); + + if ((fd = smbc_open(argv[1], O_WRONLY | O_CREAT | O_TRUNC, 0)) < 0) + { + perror("smbc_open"); + return 1; + } + + strcpy(buffer, "Hello world.\nThis is a test.\n"); + + ret = smbc_write(fd, buffer, strlen(buffer)); + savedErrno = errno; + smbc_close(fd); + + if (ret < 0) + { + errno = savedErrno; + perror("write"); + } + + if (smbc_stat(argv[1], &st) < 0) + { + perror("smbc_stat"); + return 1; + } + + printf("Original size: %lu\n", (unsigned long) st.st_size); + + if ((fd = smbc_open(argv[1], O_WRONLY, 0)) < 0) + { + perror("smbc_open"); + return 1; + } + + ret = smbc_ftruncate(fd, 13); + savedErrno = errno; + smbc_close(fd); + if (ret < 0) + { + errno = savedErrno; + perror("smbc_ftruncate"); + return 1; + } + + if (smbc_stat(argv[1], &st) < 0) + { + perror("smbc_stat"); + return 1; + } + + printf("New size: %lu\n", (unsigned long) st.st_size); + + return 0; +} diff --git a/examples/libsmbclient/testwrite.c b/examples/libsmbclient/testwrite.c new file mode 100644 index 0000000000..780f0e95da --- /dev/null +++ b/examples/libsmbclient/testwrite.c @@ -0,0 +1,69 @@ +#include <sys/types.h> +#include <stdio.h> +#include <unistd.h> +#include <string.h> +#include <time.h> +#include <errno.h> +#include <libsmbclient.h> +#include "get_auth_data_fn.h" + + +int main(int argc, char * argv[]) +{ + int i; + int fd; + int ret; + int debug = 0; + int mode = 0666; + int savedErrno; + char buffer[2048]; + char path[2048]; + char * p; + time_t t0; + time_t t1; + struct stat st; + + smbc_init(get_auth_data_fn, debug); + + printf("CAUTION: This program will overwrite a file. " + "Press ENTER to continue."); + fgets(buffer, sizeof(buffer), stdin); + + + for (;;) + { + fprintf(stdout, "\nPath: "); + *path = '\0'; + fgets(path, sizeof(path) - 1, stdin); + if (strlen(path) == 0) + { + return 0; + } + + p = path + strlen(path) - 1; + if (*p == '\n') + { + *p = '\0'; + } + + if ((fd = smbc_open(path, O_WRONLY | O_CREAT | O_TRUNC, 0)) < 0) + { + perror("smbc_open"); + continue; + } + + strcpy(buffer, "Hello world\n"); + + ret = smbc_write(fd, buffer, strlen(buffer)); + savedErrno = errno; + smbc_close(fd); + + if (ret < 0) + { + errno = savedErrno; + perror("write"); + } + } + + return 0; +} diff --git a/examples/libsmbclient/tree.c b/examples/libsmbclient/tree.c index d8a69c8d4c..6e34cd0562 100644 --- a/examples/libsmbclient/tree.c +++ b/examples/libsmbclient/tree.c @@ -8,7 +8,7 @@ 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 + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -17,14 +17,15 @@ 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. + along with this program. If not, see <http://www.gnu.org/licenses/>. */ /* example-gtk+ application, ripped off from the gtk+ tree.c sample */ #include <stdio.h> #include <errno.h> +#include <string.h> +#include <stdlib.h> #include <gtk/gtk.h> #include "libsmbclient.h" diff --git a/examples/logon/mklogon/mklogon.pl b/examples/logon/mklogon/mklogon.pl index 8bea7b22d3..870abd192c 100644 --- a/examples/logon/mklogon/mklogon.pl +++ b/examples/logon/mklogon/mklogon.pl @@ -18,8 +18,7 @@ # 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. +# along with this program; if not, see <http://www.gnu.org/licenses/>. # # Version: 1.0 (Stable) diff --git a/examples/misc/adssearch.pl b/examples/misc/adssearch.pl index 4482222934..d17e680ec8 100755 --- a/examples/misc/adssearch.pl +++ b/examples/misc/adssearch.pl @@ -3,7 +3,7 @@ # adssearch.pl - query an Active Directory server and # display objects in a human readable format # -# Copyright (C) Guenther Deschner <gd@samba.org> 2003-2007 +# Copyright (C) Guenther Deschner <gd@samba.org> 2003-2008 # # TODO: add range retrieval # write sddl-converter, decode userParameters @@ -77,6 +77,7 @@ my ( $opt_port, $opt_realm, $opt_saslmech, + $opt_search_opt, $opt_scope, $opt_simpleauth, $opt_starttls, @@ -108,6 +109,7 @@ GetOptions( 'saslmech|Y=s' => \$opt_saslmech, 'schema|c' => \$opt_dump_schema, 'scope|s=s' => \$opt_scope, + 'searchopt:i' => \$opt_search_opt, 'simpleauth|x' => \$opt_simpleauth, 'tls|Z' => \$opt_starttls, 'user|U=s' => \$opt_user, @@ -228,6 +230,7 @@ my %ads_mixed_domain = ( my %ads_ds_func = ( "DS_BEHAVIOR_WIN2000" => 0, # untested "DS_BEHAVIOR_WIN2003" => 2, +"DS_BEHAVIOR_WIN2008" => 3, ); my %ads_instance_type = ( @@ -242,6 +245,14 @@ my %ads_uacc = ( "ACCOUNT_LOCKED_OUT" => 0x800010, # 8388624 ); +my %ads_enctypes = ( + "DES-CBC-CRC" => 0x01, + "DES-CBC-MD5" => 0x02, + "RC4_HMAC_MD5" => 0x04, + "AES128_CTS_HMAC_SHA1_96" => 0x08, + "AES128_CTS_HMAC_SHA1_128" => 0x10, +); + my %ads_gpoptions = ( "GPOPTIONS_INHERIT" => 0, "GPOPTIONS_BLOCK_INHERITANCE" => 1, @@ -408,6 +419,7 @@ my %ads_gtype = ( "GTYPE_SECURITY_BUILTIN_LOCAL_GROUP" => 0x80000005, "GTYPE_SECURITY_DOMAIN_LOCAL_GROUP" => 0x80000004, "GTYPE_SECURITY_GLOBAL_GROUP" => 0x80000002, + "GTYPE_SECURITY_UNIVERSAL_GROUP" => 0x80000008, "GTYPE_DISTRIBUTION_GLOBAL_GROUP" => 0x00000002, "GTYPE_DISTRIBUTION_DOMAIN_LOCAL_GROUP" => 0x00000004, "GTYPE_DISTRIBUTION_UNIVERSAL_GROUP" => 0x00000008, @@ -486,6 +498,7 @@ if (!$password) { my %attr_handler = ( "Token-Groups-No-GC-Acceptable" => \&dump_sid, #wrong name "accountExpires" => \&dump_nttime, + "attributeSecurityGUID" => \&dump_guid, "badPasswordTime" => \&dump_nttime, "creationTime" => \&dump_nttime, "currentTime" => \&dump_timestr, @@ -514,6 +527,7 @@ my %attr_handler = ( "modifyTimeStamp" => \&dump_timestr, "msDS-Behavior-Version" => \&dump_ds_func, #unsure "msDS-User-Account-Control-Computed" => \&dump_uacc, + "msDS-SupportedEncryptionTypes" => \&dump_enctypes, "mS-DS-CreatorSID" => \&dump_sid, # "msRADIUSFramedIPAddress" => \&dump_ipaddr, # "msRASSavedFramedIPAddress" => \&dump_ipaddr, @@ -527,6 +541,7 @@ my %attr_handler = ( "pwdLastSet" => \&dump_nttime, "pwdProperties" => \&dump_pwdproperties, "sAMAccountType" => \&dump_atype, + "schemaIDGUID" => \&dump_guid, "sDRightsEffective" => \&dump_sdeffective, "securityIdentifier" => \&dump_sid, "serverState" => \&dump_serverstate, @@ -832,7 +847,8 @@ sub get_base_from_rootdse { my $server = shift || ""; $dse = shift || get_dse($server,$async_ldap_hd) || return -1; - return $dse->get_value('defaultNamingContext'); + return $dse->get_value($opt_dump_schema ? 'schemaNamingContext': + 'defaultNamingContext'); } sub get_realm_from_rootdse { @@ -1203,6 +1219,10 @@ sub dump_uacc { return dump_bitmask_equal(@_,%ads_uacc); } +sub dump_enctypes { + return dump_bitmask_and(@_,%ads_enctypes); +} + sub dump_uf { return dump_bitmask_and(@_,%ads_uf); } @@ -1461,6 +1481,21 @@ sub gen_controls { critical => 'true', value => $opt_display_extendeddn ? $ctl_extended_dn_val : ""); + # setup search options + my $search_opt = Convert::ASN1->new; + $search_opt->prepare( + q< searchopt ::= SEQUENCE { + flags INTEGER + } + > + ); + + my $tmp = $search_opt->encode( flags => $opt_search_opt); + my $ctl_search_opt = Net::LDAP::Control->new( + type => $ads_controls{'LDAP_SERVER_SEARCH_OPTIONS_OID'}, + critical => 'true', + value => $tmp); + # setup notify control my $ctl_notification = Net::LDAP::Control->new( type => $ads_controls{'LDAP_SERVER_NOTIFICATION_OID'}, @@ -1479,7 +1514,7 @@ sub gen_controls { critical => 'true', value => ""); - if (defined($opt_paging)) { + if (defined($opt_paging) || $opt_dump_schema) { push(@ctrls, $ctl_paged); push(@ctrls_s, "LDAP_PAGED_RESULT_OID_STRING" ); } @@ -1503,6 +1538,11 @@ sub gen_controls { push(@ctrls_s, "LDAP_SERVER_DOMAIN_SCOPE_OID"); } + if ($opt_search_opt) { + push(@ctrls, $ctl_search_opt); + push(@ctrls_s, "LDAP_SERVER_SEARCH_OPTIONS_OID"); + } + return @ctrls; } @@ -1762,9 +1802,9 @@ sub main () { if ($opt_dump_schema) { print "Dumping Schema:\n"; - my $ads_schema = $async_ldap_hd->schema; - $ads_schema->dump; - exit 0; +# my $ads_schema = $async_ldap_hd->schema; +# $ads_schema->dump; +# exit 0; } while (1) { @@ -1781,8 +1821,9 @@ sub main () { if (!$opt_notify && ($async_search->code == LDAP_REFERRAL)) { foreach my $ref ($async_search->referrals) { print "\ngot Referral: [$ref]\n"; + my ($prot, $host, $base) = split(/\/+/, $ref); $async_ldap_hd->unbind(); - $async_ldap_hd = get_ldap_hd($ref, 1); + $async_ldap_hd = get_ldap_hd($host, 1); if (do_bind($async_ldap_hd, $sasl_bind) == -1) { $async_ldap_hd->unbind(); next; diff --git a/examples/pam_winbind/pam_winbind.conf b/examples/pam_winbind/pam_winbind.conf index ca36e2ab00..a9e02a833a 100644 --- a/examples/pam_winbind/pam_winbind.conf +++ b/examples/pam_winbind/pam_winbind.conf @@ -9,6 +9,9 @@ # turn on debugging ;debug = no +# turn on extended PAM state debugging +;debug_state = no + # request a cached login if possible # (needs "winbind offline logon = yes" in smb.conf) ;cached_login = no @@ -24,3 +27,9 @@ # make successful authentication dependend on membership of one SID # (can also take a name) ;require_membership_of = + +# password expiry warning period in days +;warn_pwd_expire = 14 + +# omit pam conversations +;silent = no diff --git a/examples/pcap2nbench/COPYING b/examples/pcap2nbench/COPYING index a43ea2126f..94a9ed024d 100644 --- a/examples/pcap2nbench/COPYING +++ b/examples/pcap2nbench/COPYING @@ -1,285 +1,626 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 675 Mass Ave, Cambridge, MA 02139, USA + Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. - Preamble + Preamble - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of this License. - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - Appendix: How to Apply These Terms to Your New Programs + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it @@ -287,15 +628,15 @@ free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least +state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. <one line to give the program's name and a brief idea of what it does.> - Copyright (C) 19yy <name of author> + Copyright (C) <year> <name of author> - This program is free software; you can redistribute it and/or modify + 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 + the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -304,36 +645,30 @@ the "copyright" line and a pointer to where the full notice is found. 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. + along with this program. If not, see <http://www.gnu.org/licenses/>. Also add information on how to contact you by electronic and paper mail. -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: - Gnomovision version 69, Copyright (C) 19yy name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + <program> Copyright (C) <year> <name of author> + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - <signature of Ty Coon>, 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +<http://www.gnu.org/licenses/>. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +<http://www.gnu.org/philosophy/why-not-lgpl.html>. diff --git a/examples/pcap2nbench/Makefile b/examples/pcap2nbench/Makefile index fd717944c5..c1221b3876 100644 --- a/examples/pcap2nbench/Makefile +++ b/examples/pcap2nbench/Makefile @@ -5,7 +5,7 @@ ## ## 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 +## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, @@ -14,8 +14,7 @@ ## 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. +## along with this program; if not, see <http://www.gnu.org/licenses/>. ## ## Written by Anthony Liguori <aliguori@us.ibm.com> ## diff --git a/examples/pcap2nbench/closerequest.cpp b/examples/pcap2nbench/closerequest.cpp index 8487847b53..b31a1b6731 100644 --- a/examples/pcap2nbench/closerequest.cpp +++ b/examples/pcap2nbench/closerequest.cpp @@ -4,7 +4,7 @@ * * 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 + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, @@ -13,8 +13,7 @@ * 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. + * along with this program; if not, see <http://www.gnu.org/licenses/>. * * Written by Anthony Liguori <aliguori@us.ibm.com> \*/ diff --git a/examples/pcap2nbench/closerequest.hpp b/examples/pcap2nbench/closerequest.hpp index daf7ee5709..fe8866f5bc 100644 --- a/examples/pcap2nbench/closerequest.hpp +++ b/examples/pcap2nbench/closerequest.hpp @@ -4,7 +4,7 @@ * * 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 + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, @@ -13,8 +13,7 @@ * 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. + * along with this program; if not, see <http://www.gnu.org/licenses/>. * * Written by Anthony Liguori <aliguori@us.ibm.com> \*/ diff --git a/examples/pcap2nbench/ethernet.cpp b/examples/pcap2nbench/ethernet.cpp index 7fd4f1e421..4d531594e2 100644 --- a/examples/pcap2nbench/ethernet.cpp +++ b/examples/pcap2nbench/ethernet.cpp @@ -4,7 +4,7 @@ * * 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 + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, @@ -13,8 +13,7 @@ * 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. + * along with this program; if not, see <http://www.gnu.org/licenses/>. * * Written by Anthony Liguori <aliguori@us.ibm.com> \*/ diff --git a/examples/pcap2nbench/ethernet.hpp b/examples/pcap2nbench/ethernet.hpp index d00131638a..baaca5afd1 100644 --- a/examples/pcap2nbench/ethernet.hpp +++ b/examples/pcap2nbench/ethernet.hpp @@ -4,7 +4,7 @@ * * 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 + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, @@ -13,8 +13,7 @@ * 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. + * along with this program; if not, see <http://www.gnu.org/licenses/>. * * Written by Anthony Liguori <aliguori@us.ibm.com> \*/ diff --git a/examples/pcap2nbench/ip.cpp b/examples/pcap2nbench/ip.cpp index 02404c1d3c..8f1d821404 100644 --- a/examples/pcap2nbench/ip.cpp +++ b/examples/pcap2nbench/ip.cpp @@ -4,7 +4,7 @@ * * 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 + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, @@ -13,8 +13,7 @@ * 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. + * along with this program; if not, see <http://www.gnu.org/licenses/>. * * Written by Anthony Liguori <aliguori@us.ibm.com> \*/ diff --git a/examples/pcap2nbench/ip.hpp b/examples/pcap2nbench/ip.hpp index 6eca46e854..da1f0d35d1 100644 --- a/examples/pcap2nbench/ip.hpp +++ b/examples/pcap2nbench/ip.hpp @@ -4,7 +4,7 @@ * * 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 + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, @@ -13,8 +13,7 @@ * 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. + * along with this program; if not, see <http://www.gnu.org/licenses/>. * * Written by Anthony Liguori <aliguori@us.ibm.com> \*/ diff --git a/examples/pcap2nbench/main.cpp b/examples/pcap2nbench/main.cpp index 8505946205..e07b4735bd 100644 --- a/examples/pcap2nbench/main.cpp +++ b/examples/pcap2nbench/main.cpp @@ -4,7 +4,7 @@ * * 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 + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, @@ -13,8 +13,7 @@ * 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. + * along with this program; if not, see <http://www.gnu.org/licenses/>. * * Written by Anthony Liguori <aliguori@us.ibm.com> \*/ diff --git a/examples/pcap2nbench/ntcreateandxrequest.cpp b/examples/pcap2nbench/ntcreateandxrequest.cpp index d7024611f6..5efc256c61 100644 --- a/examples/pcap2nbench/ntcreateandxrequest.cpp +++ b/examples/pcap2nbench/ntcreateandxrequest.cpp @@ -4,7 +4,7 @@ * * 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 + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, @@ -13,8 +13,7 @@ * 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. + * along with this program; if not, see <http://www.gnu.org/licenses/>. * * Written by Anthony Liguori <aliguori@us.ibm.com> \*/ diff --git a/examples/pcap2nbench/ntcreateandxrequest.hpp b/examples/pcap2nbench/ntcreateandxrequest.hpp index 0e80c88308..07c19fdc8a 100644 --- a/examples/pcap2nbench/ntcreateandxrequest.hpp +++ b/examples/pcap2nbench/ntcreateandxrequest.hpp @@ -4,7 +4,7 @@ * * 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 + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, @@ -13,8 +13,7 @@ * 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. + * along with this program; if not, see <http://www.gnu.org/licenses/>. * * Written by Anthony Liguori <aliguori@us.ibm.com> \*/ diff --git a/examples/pcap2nbench/ntcreateandxresponse.cpp b/examples/pcap2nbench/ntcreateandxresponse.cpp index 5f2ab02777..7e427b9716 100644 --- a/examples/pcap2nbench/ntcreateandxresponse.cpp +++ b/examples/pcap2nbench/ntcreateandxresponse.cpp @@ -4,7 +4,7 @@ * * 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 + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, @@ -13,8 +13,7 @@ * 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. + * along with this program; if not, see <http://www.gnu.org/licenses/>. * * Written by Anthony Liguori <aliguori@us.ibm.com> \*/ diff --git a/examples/pcap2nbench/ntcreateandxresponse.hpp b/examples/pcap2nbench/ntcreateandxresponse.hpp index fbe2f0cfbb..c17ff21f55 100644 --- a/examples/pcap2nbench/ntcreateandxresponse.hpp +++ b/examples/pcap2nbench/ntcreateandxresponse.hpp @@ -4,7 +4,7 @@ * * 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 + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, @@ -13,8 +13,7 @@ * 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. + * along with this program; if not, see <http://www.gnu.org/licenses/>. * * Written by Anthony Liguori <aliguori@us.ibm.com> \*/ diff --git a/examples/pcap2nbench/readandxrequest.cpp b/examples/pcap2nbench/readandxrequest.cpp index a903deeecb..87411fc0c9 100644 --- a/examples/pcap2nbench/readandxrequest.cpp +++ b/examples/pcap2nbench/readandxrequest.cpp @@ -4,7 +4,7 @@ * * 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 + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, @@ -13,8 +13,7 @@ * 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. + * along with this program; if not, see <http://www.gnu.org/licenses/>. * * Written by Anthony Liguori <aliguori@us.ibm.com> \*/ diff --git a/examples/pcap2nbench/readandxrequest.hpp b/examples/pcap2nbench/readandxrequest.hpp index 6b590f882f..21e0bca3b3 100644 --- a/examples/pcap2nbench/readandxrequest.hpp +++ b/examples/pcap2nbench/readandxrequest.hpp @@ -4,7 +4,7 @@ * * 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 + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, @@ -13,8 +13,7 @@ * 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. + * along with this program; if not, see <http://www.gnu.org/licenses/>. * * Written by Anthony Liguori <aliguori@us.ibm.com> \*/ diff --git a/examples/pcap2nbench/readandxresponse.hpp b/examples/pcap2nbench/readandxresponse.hpp index 84ac07b969..0a302cb657 100644 --- a/examples/pcap2nbench/readandxresponse.hpp +++ b/examples/pcap2nbench/readandxresponse.hpp @@ -4,7 +4,7 @@ * * 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 + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, @@ -13,8 +13,7 @@ * 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. + * along with this program; if not, see <http://www.gnu.org/licenses/>. * * Written by Anthony Liguori <aliguori@us.ibm.com> \*/ diff --git a/examples/pcap2nbench/smb.cpp b/examples/pcap2nbench/smb.cpp index df3f84b4af..78f8aaf23a 100644 --- a/examples/pcap2nbench/smb.cpp +++ b/examples/pcap2nbench/smb.cpp @@ -4,7 +4,7 @@ * * 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 + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, @@ -13,8 +13,7 @@ * 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. + * along with this program; if not, see <http://www.gnu.org/licenses/>. * * Written by Anthony Liguori <aliguori@us.ibm.com> \*/ diff --git a/examples/pcap2nbench/smb.hpp b/examples/pcap2nbench/smb.hpp index 8afda670d2..79a7f8c415 100644 --- a/examples/pcap2nbench/smb.hpp +++ b/examples/pcap2nbench/smb.hpp @@ -4,7 +4,7 @@ * * 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 + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, @@ -13,8 +13,7 @@ * 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. + * along with this program; if not, see <http://www.gnu.org/licenses/>. * * Written by Anthony Liguori <aliguori@us.ibm.com> \*/ diff --git a/examples/pcap2nbench/tcp.cpp b/examples/pcap2nbench/tcp.cpp index 3dff4bda31..8b5106011a 100644 --- a/examples/pcap2nbench/tcp.cpp +++ b/examples/pcap2nbench/tcp.cpp @@ -4,7 +4,7 @@ * * 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 + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, @@ -13,8 +13,7 @@ * 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. + * along with this program; if not, see <http://www.gnu.org/licenses/>. * * Written by Anthony Liguori <aliguori@us.ibm.com> \*/ diff --git a/examples/pcap2nbench/tcp.hpp b/examples/pcap2nbench/tcp.hpp index f659499f7e..5eb7aaaa66 100644 --- a/examples/pcap2nbench/tcp.hpp +++ b/examples/pcap2nbench/tcp.hpp @@ -4,7 +4,7 @@ * * 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 + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, @@ -13,8 +13,7 @@ * 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. + * along with this program; if not, see <http://www.gnu.org/licenses/>. * * Written by Anthony Liguori <aliguori@us.ibm.com> \*/ diff --git a/examples/pcap2nbench/writeandxrequest.cpp b/examples/pcap2nbench/writeandxrequest.cpp index 68c5a2b05d..f56a03168c 100644 --- a/examples/pcap2nbench/writeandxrequest.cpp +++ b/examples/pcap2nbench/writeandxrequest.cpp @@ -4,7 +4,7 @@ * * 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 + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, @@ -13,8 +13,7 @@ * 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. + * along with this program; if not, see <http://www.gnu.org/licenses/>. * * Written by Anthony Liguori <aliguori@us.ibm.com> \*/ diff --git a/examples/pcap2nbench/writeandxrequest.hpp b/examples/pcap2nbench/writeandxrequest.hpp index 3a0c84008e..c91bcc3b14 100644 --- a/examples/pcap2nbench/writeandxrequest.hpp +++ b/examples/pcap2nbench/writeandxrequest.hpp @@ -4,7 +4,7 @@ * * 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 + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, @@ -13,8 +13,7 @@ * 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. + * along with this program; if not, see <http://www.gnu.org/licenses/>. * * Written by Anthony Liguori <aliguori@us.ibm.com> \*/ diff --git a/examples/pdb/test.c b/examples/pdb/test.c index c553f72f0b..b5ddefc480 100644 --- a/examples/pdb/test.c +++ b/examples/pdb/test.c @@ -4,7 +4,7 @@ * * 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) + * Software Foundation; either version 3 of the License, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, but WITHOUT @@ -13,8 +13,7 @@ * 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. + * this program; if not, see <http://www.gnu.org/licenses/>. */ diff --git a/examples/perfcounter/Makefile b/examples/perfcounter/Makefile index 07bc7657c9..925e2ea080 100644 --- a/examples/perfcounter/Makefile +++ b/examples/perfcounter/Makefile @@ -3,7 +3,7 @@ # # 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 +# the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, @@ -12,26 +12,26 @@ # 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. +# along with this program; if not, see <http://www.gnu.org/licenses/>. # SAMBA_SRC_DIR=../../source TDB_SRC_DIR=$(SAMBA_SRC_DIR)/tdb -CFLAGS = -g -I$(SAMBA_SRC_DIR)/include -I$(TDB_SRC_DIR) +CFLAGS = -g -I$(SAMBA_SRC_DIR)/include -I$(TDB_SRC_DIR)/include CC = gcc PROGS = perfcount -TDB_OBJ = $(TDB_SRC_DIR)/tdb.o $(TDB_SRC_DIR)/spinlock.o $(TDB_SRC_DIR)/tdbback.o +TDB_OBJ = $(TDB_SRC_DIR)/common/tdb.o $(TDB_SRC_DIR)/common/dump.o \ + $(TDB_SRC_DIR)/common/error.o $(TDB_SRC_DIR)/common/freelist.o \ + $(TDB_SRC_DIR)/common/io.o $(TDB_SRC_DIR)/common/lock.o \ + $(TDB_SRC_DIR)/common/open.o $(TDB_SRC_DIR)/common/transaction.o \ + $(TDB_SRC_DIR)/common/traverse.o PERF_WRITER_OBJ = perf_writer.o perf_writer_mem.o perf_writer_util.o perf_writer_cpu.o perf_writer_process.o perf_writer_disk.o default: $(PROGS) -$(TDB_OBJ): - cd $(TDB_SRC_DIR) && make - -perfcount: $(PERF_WRITER_OBJ) $(TDB_OBJ) +perfcount: $(PERF_WRITER_OBJ) $(CC) $(CFLAGS) -o perfcount $(PERF_WRITER_OBJ) $(TDB_OBJ) clean: diff --git a/examples/perfcounter/perf.h b/examples/perfcounter/perf.h index 7279e78831..2c24d31260 100644 --- a/examples/perfcounter/perf.h +++ b/examples/perfcounter/perf.h @@ -6,7 +6,7 @@ * * 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 + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, @@ -15,8 +15,7 @@ * 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. + * along with this program; if not, see <http://www.gnu.org/licenses/>. */ #ifndef __PERF_H__ diff --git a/examples/perfcounter/perf_writer.c b/examples/perfcounter/perf_writer.c index 00e47bdaba..4260f9595d 100644 --- a/examples/perfcounter/perf_writer.c +++ b/examples/perfcounter/perf_writer.c @@ -6,7 +6,7 @@ * * 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 + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, @@ -15,8 +15,7 @@ * 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. + * along with this program; if not, see <http://www.gnu.org/licenses/>. */ #include "perf.h" diff --git a/examples/perfcounter/perf_writer_cpu.c b/examples/perfcounter/perf_writer_cpu.c index 7786c9415e..215e073b8d 100644 --- a/examples/perfcounter/perf_writer_cpu.c +++ b/examples/perfcounter/perf_writer_cpu.c @@ -6,7 +6,7 @@ * * 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 + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, @@ -15,8 +15,7 @@ * 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. + * along with this program; if not, see <http://www.gnu.org/licenses/>. */ #include "perf.h" diff --git a/examples/perfcounter/perf_writer_disk.c b/examples/perfcounter/perf_writer_disk.c index b2b4c9690b..15188d2531 100644 --- a/examples/perfcounter/perf_writer_disk.c +++ b/examples/perfcounter/perf_writer_disk.c @@ -6,7 +6,7 @@ * * 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 + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, @@ -15,8 +15,7 @@ * 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. + * along with this program; if not, see <http://www.gnu.org/licenses/>. */ #include "perf.h" diff --git a/examples/perfcounter/perf_writer_mem.c b/examples/perfcounter/perf_writer_mem.c index 1a9a3ca959..580207fb64 100644 --- a/examples/perfcounter/perf_writer_mem.c +++ b/examples/perfcounter/perf_writer_mem.c @@ -6,7 +6,7 @@ * * 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 + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, @@ -15,8 +15,7 @@ * 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. + * along with this program; if not, see <http://www.gnu.org/licenses/>. */ #include "perf.h" diff --git a/examples/perfcounter/perf_writer_process.c b/examples/perfcounter/perf_writer_process.c index 75a23dae51..bddceeab15 100644 --- a/examples/perfcounter/perf_writer_process.c +++ b/examples/perfcounter/perf_writer_process.c @@ -6,7 +6,7 @@ * * 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 + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, @@ -15,8 +15,7 @@ * 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. + * along with this program; if not, see <http://www.gnu.org/licenses/>. */ #include "perf.h" diff --git a/examples/perfcounter/perf_writer_util.c b/examples/perfcounter/perf_writer_util.c index 78a99fef49..6f1eb16d3e 100644 --- a/examples/perfcounter/perf_writer_util.c +++ b/examples/perfcounter/perf_writer_util.c @@ -6,7 +6,7 @@ * * 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 + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, @@ -15,8 +15,7 @@ * 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. + * along with this program; if not, see <http://www.gnu.org/licenses/>. */ #include "perf.h" @@ -37,10 +36,6 @@ void add_key_raw(TDB_CONTEXT *db, char *keystring, void *databuf, size_t datasiz key.dsize = strlen(keystring); data.dptr = databuf; data.dsize = datasize; - fprintf(stderr, "doing insert of [%x] with key [%s] into [%s]\n", - data.dptr, - keystring, - db->name); tdb_store(db, key, data, flags); } @@ -53,10 +48,6 @@ void add_key(TDB_CONTEXT *db, char *keystring, char *datastring, int flags) key.dsize = strlen(keystring); data.dptr = datastring; data.dsize = strlen(datastring); - /* fprintf(stderr, "doing insert of [%s] with key [%s] into [%s]\n", - data.dptr, - keystring, - db->name);*/ tdb_store(db, key, data, flags); } diff --git a/examples/perfcounter/perfcountd.init b/examples/perfcounter/perfcountd.init index bb4148e52f..683e91395b 100755 --- a/examples/perfcounter/perfcountd.init +++ b/examples/perfcounter/perfcountd.init @@ -4,7 +4,7 @@ # # 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 +# the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, @@ -13,8 +13,7 @@ # 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. +# along with this program; if not, see <http://www.gnu.org/licenses/>. # #################################################################### diff --git a/examples/printing/VampireDriversFunctions b/examples/printing/VampireDriversFunctions index ea0cf47295..3d46411e91 100644 --- a/examples/printing/VampireDriversFunctions +++ b/examples/printing/VampireDriversFunctions @@ -8,7 +8,7 @@ ## ## 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 +## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, @@ -17,8 +17,7 @@ ## 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. +## along with this program; if not, see <http://www.gnu.org/licenses/>. ## ###################################################################### diff --git a/examples/printing/prtpub.c b/examples/printing/prtpub.c index ea71e03d07..2839940b97 100644 --- a/examples/printing/prtpub.c +++ b/examples/printing/prtpub.c @@ -4,7 +4,7 @@ * * 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 + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, @@ -13,8 +13,7 @@ * 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. + * along with this program; if not, see <http://www.gnu.org/licenses/>. */ /* This needs to be defined for certain compilers */ diff --git a/examples/scripts/eventlog/parselog.pl b/examples/scripts/eventlog/parselog.pl index 61a07542da..0c21a94103 100644 --- a/examples/scripts/eventlog/parselog.pl +++ b/examples/scripts/eventlog/parselog.pl @@ -7,7 +7,7 @@ ## ## 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 +## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, @@ -16,8 +16,7 @@ ## 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. +## along with this program; if not, see <http://www.gnu.org/licenses/>. ## ###################################################################### diff --git a/examples/scripts/mount/mount.smbfs b/examples/scripts/mount/mount.smbfs new file mode 100644 index 0000000000..3b57bc5141 --- /dev/null +++ b/examples/scripts/mount/mount.smbfs @@ -0,0 +1,115 @@ +#!/bin/bash +# Debian mount.smbfs compatibility wrapper +# Copyright 2007, Steve Langasek <vorlon at debian.org> +# Licensed under the GNU General Public License, version 2. See the +# file /usr/share/common-licenses/GPL or <http://www.gnu.org/copyleft/gpl.txt>. + +# This script accepts all documented mount options for mount.smbfs, +# passing through those that are also recognized by mount.cifs, +# converting those that are not recognized but map to available cifs +# options, and warning about the use of options for which no equivalent +# exists. + +# known bugs: quoted spaces in arguments are not passed intact + +set -e + +# reverse the order of username and password in a "username" parameter, +# taking care to leave any "%password" bit intact + +reverse_username_workgroup() { + local workgroup password username + + username="$1" + case "$username" in + *%*) password="${username#*%}" + username="${username%%%*}" + ;; + *) ;; + esac + case "$username" in + */*) workgroup="${username#*/}" + username="${username%%/*}" + ;; + *) ;; + esac + if [ -n "$workgroup" ]; then + username="$workgroup\\$username" + fi + if [ -n "$password" ]; then + username="$username%$password" + fi + echo "$username" +} + + +# parse out the mount options that have been specified using -o, and if +# necessary, convert them for use by mount.cifs + +parse_mount_options () { + local OLD_IFS IFS options option username + OLD_IFS="$IFS" + IFS="," + options="" + workgroup="" + password="" + + for option in $@; do + case "$option" in + sockopt=* | scope=* | codepage=* | ttl=* | debug=*) + echo "Warning: ignoring deprecated smbfs option '$option'" >&2 + ;; + + krb) + options="$options${options:+,}sec=krb5" + ;; + + guest) + echo "Warning: mapping 'guest' to 'guest,sec=none'" >&2 + options="$options${options:+,}guest,sec=none" + ;; + + # username and workgroup are reversed in username= arguments, + # so need to be parsed out + username=*/*) + IFS="$OLD_IFS" + username="${option#username=}" + username="$(reverse_username_workgroup "$username")" + IFS="," + options="$options${options:+,}username=$username" + ;; + + *) + options="$options${options:+,}$option" + ;; + esac + done + IFS="$OLD_IFS" + echo $options +} + +args=() +while [ "$#" -gt 0 ]; do + case "$1" in + -o*) + arg=${1#-o} + shift + if [ -z "$arg" ]; then + arg=$1 + shift + fi + arg="$(parse_mount_options "$arg")" + if [ -n "$arg" ]; then + args=("${args[@]}" "-o" "$arg") + fi + ;; + *) + args=("${args[@]}" "$1") + shift + ;; + esac +done + +USER="$(reverse_username_workgroup "$USER")" + +exec /sbin/mount.cifs "${args[@]}" diff --git a/examples/scripts/printing/cups/smbaddprinter.pl b/examples/scripts/printing/cups/smbaddprinter.pl index 557183140e..aee2020bfc 100755 --- a/examples/scripts/printing/cups/smbaddprinter.pl +++ b/examples/scripts/printing/cups/smbaddprinter.pl @@ -5,7 +5,7 @@ ## 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 +## Either version 3 of the License, or (at your option) any ## later version. ## ## This program is distributed in the hope that it will be useful, @@ -14,9 +14,7 @@ ## 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. +## License along with this program; if not, see <http://www.gnu.org/licenses/>. @argv = @ARGV; diff --git a/examples/scripts/printing/cups/smbdelprinter.pl b/examples/scripts/printing/cups/smbdelprinter.pl index 30daf24b35..23adeb719c 100755 --- a/examples/scripts/printing/cups/smbdelprinter.pl +++ b/examples/scripts/printing/cups/smbdelprinter.pl @@ -5,7 +5,7 @@ ## 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 +## Either version 3 of the License, or (at your option) any ## later version. ## ## This program is distributed in the hope that it will be useful, @@ -14,9 +14,7 @@ ## 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. +## License along with this program; if not, see <http://www.gnu.org/licenses/>. @argv = @ARGV; diff --git a/examples/scripts/shares/perl/modify_samba_config.pl b/examples/scripts/shares/perl/modify_samba_config.pl index aaf2958a95..20b613aba8 100755 --- a/examples/scripts/shares/perl/modify_samba_config.pl +++ b/examples/scripts/shares/perl/modify_samba_config.pl @@ -8,7 +8,7 @@ ## ## 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 +## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, @@ -17,8 +17,7 @@ ## 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. +## along with this program; if not, see <http://www.gnu.org/licenses/>. ## ###################################################################### diff --git a/examples/scripts/shares/python/SambaConfig.py b/examples/scripts/shares/python/SambaConfig.py index c70c23118a..3d4a47398c 100644 --- a/examples/scripts/shares/python/SambaConfig.py +++ b/examples/scripts/shares/python/SambaConfig.py @@ -9,7 +9,7 @@ from smbparm import parm_table ## ## 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 +## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, @@ -18,8 +18,7 @@ from smbparm import parm_table ## 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. +## along with this program; if not, see <http://www.gnu.org/licenses/>. ## ###################################################################### diff --git a/examples/scripts/shares/python/SambaParm.py b/examples/scripts/shares/python/SambaParm.py index 292ad42cd2..82c99c84ac 100644 --- a/examples/scripts/shares/python/SambaParm.py +++ b/examples/scripts/shares/python/SambaParm.py @@ -6,7 +6,7 @@ ## ## 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 +## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, @@ -15,8 +15,7 @@ ## 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. +## along with this program; if not, see <http://www.gnu.org/licenses/>. ## ###################################################################### diff --git a/examples/scripts/shares/python/generate_parm_table.py b/examples/scripts/shares/python/generate_parm_table.py index 1dbc071e9b..1d2c5f246c 100755 --- a/examples/scripts/shares/python/generate_parm_table.py +++ b/examples/scripts/shares/python/generate_parm_table.py @@ -7,7 +7,7 @@ ## ## 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 +## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, @@ -16,8 +16,7 @@ ## 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. +## along with this program; if not, see <http://www.gnu.org/licenses/>. ## ###################################################################### @@ -32,7 +31,7 @@ HEADER = """#################################################################### ## ## 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 +## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, @@ -41,8 +40,7 @@ HEADER = """#################################################################### ## 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. +## along with this program; if not, see <http://www.gnu.org/licenses/>. ## ###################################################################### diff --git a/examples/scripts/shares/python/modify_samba_config.py b/examples/scripts/shares/python/modify_samba_config.py index 6a4cdcab79..88b3fcb394 100755 --- a/examples/scripts/shares/python/modify_samba_config.py +++ b/examples/scripts/shares/python/modify_samba_config.py @@ -7,7 +7,7 @@ ## ## 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 +## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, @@ -16,8 +16,7 @@ ## 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. +## along with this program; if not, see <http://www.gnu.org/licenses/>. ## ###################################################################### diff --git a/examples/scripts/shares/python/smbparm.py b/examples/scripts/shares/python/smbparm.py index 0dfcf0062e..73637a7095 100644 --- a/examples/scripts/shares/python/smbparm.py +++ b/examples/scripts/shares/python/smbparm.py @@ -7,7 +7,7 @@ ## ## 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 +## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, @@ -16,8 +16,7 @@ ## 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. +## along with this program; if not, see <http://www.gnu.org/licenses/>. ## ###################################################################### diff --git a/examples/scripts/users_and_groups/adduserstogroups.pl b/examples/scripts/users_and_groups/adduserstogroups.pl new file mode 100755 index 0000000000..6759428774 --- /dev/null +++ b/examples/scripts/users_and_groups/adduserstogroups.pl @@ -0,0 +1,166 @@ +#!/usr/bin/perl + +# +# adduserstogroups.pl +# +# add single or continuously numbered domain users +# to a given single group or list of groups +# +# Copyright (C) Michael Adam <obnox@samba.org> 2007 +# +# 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 3 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, see <http://www.gnu.org/licenses/>. +# + +# +# WARNING: This script is still rather crude. +# + +use strict; +use Getopt::Std; + +my $net_cmd = "net"; + +# defaults: + +my $server; +my $num_members = 1; +my $startmem; # if empty, don't add numbers to member prefix +my $member_prefix; # name prefix for member +my $num_groups = 1; +my $startgroup; # if empty, don't add numbers to group prefix +my $group_prefix; # name prefix for group +my $path; # path to rpcclient command +my $net_path = $net_cmd; +my $creds; + +sub usage { + print "USAGE: $0 [-h] -S server -U user\%pass \\\n" + . "\t-m member [-s startmem] [-n nummem] \\\n" + . "\t-g group [-G startgroup] [-N numgroups] \\\n" + . "\t[-P path]\n"; +} + +# parse commandline: + +my %options = (); +getopts("U:S:m:s:n:g:G:N:P:h", \%options); + +if (exists($options{h})) { + usage(); + exit 0; +} + +if (exists($options{g})) { + $group_prefix = $options{g}; +} +else { + print "ERROR: mandatory argument '-g' missing\n"; + usage(); + exit 1; +} + +if (exists($options{U})) { + $creds = "-U $options{U}"; + if ($creds !~ '%') { + print "ERROR: you need to specify credentials in the form -U user\%pass\n"; + usage(); + exit 1; + } +} +else { + print "ERROR: mandatory argument '-U' missing\n"; + usage(); + exit 1; +} + +if (exists($options{S})) { + $server = $options{S}; +} +else { + print "ERROR: madatory argument '-S' missing\n"; + usage(); + exit 1; +} + +if (exists($options{s})) { + $startmem = $options{s}; +} + +if (exists($options{n})) { + $num_members = $options{n}; +} + +if (exists($options{m})) { + $member_prefix = $options{m}; +} +else { + print "ERROR: mandatory argument '-m' missing\n"; + usage(); + exit 1; +} + +if (exists($options{G})) { + $startgroup = $options{G}; +} + +if (exists($options{N})) { + $num_groups = $options{N}; +} + +if (exists($options{P})) { + $path = $options{p}; + $net_path = "$path/$net_cmd"; +} + +if (@ARGV) { + print "ERROR: junk on the command line ('" . join(" ", @ARGV) . "')...\n"; + usage(); + exit 1; +} + +# utility functions: + +sub do_add { + my $member_name = shift; + my $group_name = shift; + print "adding member $member_name to group $group_name\n"; + system("$net_path rpc -I $server ".$creds." group addmem $group_name $member_name"); +} + +sub add_group_loop { + my $member_name = shift; + + if ("x$startgroup" eq "x") { + do_add($member_name, $group_prefix); + } + else { + for (my $groupnum = 1; $groupnum <= $num_groups; ++$groupnum) { + do_add($member_name, + sprintf("%s%.05d", $group_prefix, $startgroup + $groupnum - 1)); + } + } +} + + +# main: + +if ("x$startmem" eq "x") { + add_group_loop($member_prefix); +} +else { + for (my $memnum = 1; $memnum <= $num_members; ++$memnum) { + add_group_loop(sprintf("%s%.05d", $member_prefix, $startmem + $memnum - 1)); + } +} + diff --git a/examples/scripts/users_and_groups/createdomobj.pl b/examples/scripts/users_and_groups/createdomobj.pl new file mode 100755 index 0000000000..60f34b84f2 --- /dev/null +++ b/examples/scripts/users_and_groups/createdomobj.pl @@ -0,0 +1,157 @@ +#!/usr/bin/perl + +# +# createdomobj.pl +# +# create single or continuously numbered domain +# users/groups/aliases via rpc +# +# Copyright (C) Michael Adam <obnox@samba.org> 2007 +# +# 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 3 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, see <http://www.gnu.org/licenses/>. +# + +# +# WARNING: This script is still rather crude. +# + +use strict; +use Getopt::Std; + + +my $target_type = "group"; # what type of object to create +my $rpc_cmd = "createdom".$target_type; +my $rpccli_cmd = "rpcclient"; + +# defaults: + +my $server; +my $num_targets = 1; +my $startnum; # if empty, don't add numbers to prefix +my $prefix = $target_type; # name-prefix +my $path; # path to rpcclient command +my $rpccli_path = $rpccli_cmd; +my $creds; + +sub usage { + print "USAGE: $0 [-h] -S server -U user\%pass [-p prefix] \\\n" + . "\t[-t {alias|group|user}] [-s startnum] [-n numobjs] [-P path] \n"; +} + +# parse commandline: + +my %options = (); +getopts("U:t:S:s:n:p:P:h", \%options); + +if (exists($options{h})) { + usage(); + exit 0; +} + +if (exists($options{t})) { + $target_type = $options{t}; + if ($target_type !~ /^(alias|user|group)$/) { + print "ERROR: invalid target type given\n"; + usage(); + exit 1; + } + $rpc_cmd = "createdom".$target_type; +} + +if (exists($options{U})) { + $creds = "-U $options{U}"; + if ($creds !~ '%') { + print "ERROR: you need to specify credentials in the form -U user\%pass\n"; + usage(); + exit 1; + } +} +else { + print "ERROR: mandatory argument '-U' missing\n"; + usage(); + exit 1; +} + +if (exists($options{S})) { + $server = $options{S}; +} +else { + print "ERROR: madatory argument '-S' missing\n"; + usage(); + exit 1; +} + +if (exists($options{s})) { + $startnum = $options{s}; +} + +if (exists($options{n})) { + $num_targets = $options{n}; +} + +if (exists($options{p})) { + $prefix = $options{p}; +} + +if (exists($options{P})) { + $path = $options{p}; + $rpccli_path = "$path/$rpccli_cmd"; +} + +if (@ARGV) { + print "ERROR: junk on the command line ('" . join(" ", @ARGV) . "')...\n"; + usage(); + exit 1; +} + +# utility functions: + +sub open_rpc_pipe { + print "opening rpc pipe\n"; + open(IPC, "| $rpccli_cmd $server $creds -d0") or + die "error opening rpc pipe."; +} + +sub close_rpc_pipe { + print "closing rpc pipe\n"; + close(IPC); +} + +sub do_create { + my $target_name = shift; + print "creating $target_type $target_name\n"; + print IPC "$rpc_cmd $target_name\n"; +} + +# main: + +open_rpc_pipe(); + +if ("x$startnum" eq "x") { + do_create($prefix); +} +else { + for (my $num = 1; $num <= $num_targets; ++$num) { + do_create(sprintf "%s%.05d", $prefix, $startnum + $num - 1); + if (($num) % 500 == 0) { + printf("500 ".$target_type."s created\n"); + close_rpc_pipe(); + sleep 2; + open_rpc_pipe(); + } + } +} + +close_rpc_pipe(); + |