[Samba] inter domain trust not working

2012-11-06 Thread Razvan Cosma
 Hello,
I am trying to make a RHEL6 box (samba-winbind-3.5.10-125.el6.x86_64)
accept logins from a trusted domain; all is working fine for the primary
domain, pam_winbind+pam_mkhomedir allow logins for domain users, when
checking the trusted one though

# net rpc trustdom list -Utest%pass
 Trusted domains list:
 TRUSTED S-1-2-5-etcetc
 Unable to find a suitable server for domain TRUSTED
 domain controller is not responding: NT_STATUS_UNSUCCESSFUL
 TRUSTED  couldn't get domain's sid

There are no trusting domains set.

A tcpdump while running the above command shows the client connecting to
the primary domain controller (which also has all the other roles), then
making a DNS query for
 SRV? _ldap._tcp.pdc._msdcs.TRUSTED.
to which it gets a NXDomain
This query should not be made, and will not get an answer, the correct one
would be
SRV? _ldap._tcp.pdc._msdcs.TRUSTED.LOCAL
which does exist and returns all the SRV records as expected

Windows clients do work in the same network/VLAN; any hints on what makes
Samba choke after that query are greatly appreciated.

For reference,
smb.conf:
workgroup = PRIMARY
password server = thedc.primary.local
winbind use default domain = no
realm = PRIMARY.LOCAL
security = ads
encrypt passwords = yes
krb5.conf:
[libdefaults]
 default_realm = PRIMARY.LOCAL
 dns_lookup_realm = yes
 dns_lookup_kdc = yes
 forwardable = false
[realms]
 PRIMARY.LOCAL = {
 }
 TRUSTED.LOCAL = {
 }
[domain_realm]
 .primary.local = PRIMARY.LOCAL
 primary.local = PRIMARY.LOCAL
 .trusted.local = TRUSTED.LOCAL
 trusted.local = TRUSTED.LOCAL
(yes, the realm definitions are empty, as everything should work via DNS. I
have also tried specifying admin_server,default_domain and kdc for the
trusted realm, no dice)

thedc.primary.local is set in resolv.conf on the client
-- 
To unsubscribe from this list go to the following URL and read the
instructions:  https://lists.samba.org/mailman/options/samba


[Samba] another one of those "cannot authenticate against AD" posts :(

2003-09-25 Thread Razvan Cosma
  Hello,
I had a perfectly good setup with samba being a domain member, and 
domain users accessing their shares, since beta1. A month and several 
updates from M$ later, clients were no longer able to log on to the 
samba machine. I know this must be related to the updates, since there 
have been absolutely no configuration / application modifications on the 
linux box, and clients who forgot to install the patches were still able 
to login.
Hint for the docs: the bloody windows update rewrote the rtfm 
signorseal registry key, but that can be enforced globally from the 
domain controller.
Now I'm trying with the latest beta - or first stable, as you call it 
since yesterday :)
Status:
- linux box joins fine the AD
- kinit -v, smbclient -k, net ads whatever work as expected, no errors
- no one can login to the samba box. Win 2k/xp report the 
username/password is incorrect, and the logs state:

[2003/09/25 20:20:01, 3] smbd/process.c:process_smb(890)
 Transaction 10 of length 250
[2003/09/25 20:20:01, 3] smbd/process.c:switch_message(685)
 switch message SMBsesssetupX (pid 343)
[2003/09/25 20:20:01, 3] smbd/sec_ctx.c:set_sec_ctx(288)
 setting sec ctx (0, 0) - sec_ctx_stack_ndx = 0
[2003/09/25 20:20:01, 3] smbd/sesssetup.c:reply_sesssetup_and_X(579)
 wct=12 flg2=0xc807
[2003/09/25 20:20:01, 3] smbd/sesssetup.c:reply_sesssetup_and_X_spnego(476)
 Doing spnego session setup
[2003/09/25 20:20:01, 3] smbd/sesssetup.c:reply_sesssetup_and_X_spnego(500)
 NativeOS=[Windows 2002 2600 Service Pack 1] NativeLanMan=[Windows 2002 
5.1]
[2003/09/25 20:20:01, 3] smbd/sesssetup.c:reply_spnego_negotiate(385)
 Got OID 1 3 6 1 4 1 311 2 2 10
[2003/09/25 20:20:01, 3] smbd/sesssetup.c:reply_spnego_negotiate(388)
 Got secblob of size 50
[2003/09/25 20:20:01, 3] libsmb/ntlmssp.c:debug_ntlmssp_flags(33)
 Got NTLMSSP neg_flags=0xe008b297
[2003/09/25 20:20:01, 3] smbd/process.c:process_smb(890)
 Transaction 11 of length 338
[2003/09/25 20:20:01, 3] smbd/process.c:switch_message(685)
 switch message SMBsesssetupX (pid 343)
[2003/09/25 20:20:01, 3] smbd/sec_ctx.c:set_sec_ctx(288)
 setting sec ctx (0, 0) - sec_ctx_stack_ndx = 0
[2003/09/25 20:20:01, 3] smbd/sesssetup.c:reply_sesssetup_and_X(579)
 wct=12 flg2=0xc807
[2003/09/25 20:20:01, 3] smbd/sesssetup.c:reply_sesssetup_and_X_spnego(476)
 Doing spnego session setup
[2003/09/25 20:20:01, 3] smbd/sesssetup.c:reply_sesssetup_and_X_spnego(500)
 NativeOS=[Windows 2002 2600 Service Pack 1] NativeLanMan=[Windows 2002 
5.1]
[2003/09/25 20:20:01, 3] libsmb/ntlmssp.c:ntlmssp_server_auth(286)
 Got user=[Thatsme] domain=[Mydomain] workstation=[Mine] len1=24 len2=24
[2003/09/25 20:20:01, 3] auth/auth.c:check_ntlm_password(216)
 check_ntlm_password:  Checking password for unmapped user 
[EMAIL PROTECTED] with the new password interface
[2003/09/25 20:20:01, 3] auth/auth.c:check_ntlm_password(219)
 check_ntlm_password:  mapped user is: [EMAIL PROTECTED]
[2003/09/25 20:20:01, 3] smbd/sec_ctx.c:push_sec_ctx(256)
 push_sec_ctx(0, 0) : sec_ctx_stack_ndx = 1
[2003/09/25 20:20:01, 3] smbd/uid.c:push_conn_ctx(287)
 push_conn_ctx(0) : conn_ctx_stack_ndx = 0
[2003/09/25 20:20:01, 3] smbd/sec_ctx.c:set_sec_ctx(288)
 setting sec ctx (0, 0) - sec_ctx_stack_ndx = 1
[2003/09/25 20:20:01, 3] smbd/sec_ctx.c:pop_sec_ctx(386)
 pop_sec_ctx (0, 0) - sec_ctx_stack_ndx = 0
[2003/09/25 20:20:01, 3] auth/auth_util.c:make_server_info_info3(1009)
 User Thatsme does not exist, trying to add it
[2003/09/25 20:20:01, 0] auth/auth_util.c:make_server_info_info3(1017)

 make_server_info_info3: pdb_init_sam failed!
... I don't understand this one ..
[2003/09/25 20:20:01, 2] auth/auth.c:check_ntlm_password(309)

 check_ntlm_password:  Authentication for user [Thatsme] -> [Thatsme] 
FAILED with error NT_STATUS_NO_SUCH_USER
... and I definitely have a domain logon ..

[2003/09/25 20:20:04, 3] smbd/process.c:timeout_processing(1099)
 timeout_processing: End of file from client (client has disconnected).
I tried raising the debug level info and got some interesting lines:

[2003/09/25 23:03:09, 10] libads/kerberos_verify.c:ads_verify_ticket(310)
 ads_verify_ticket: enc type [16] failed to decrypt with error Bad 
encryption type
[2003/09/25 23:03:09, 10] libads/kerberos_verify.c:ads_verify_ticket(303)
 ads_verify_ticket: enc type [3] decrypted message !
[2003/09/25 23:03:09, 10] passdb/secrets.c:secrets_named_mutex_release(709)
 secrets_named_mutex: released mutex for replay cache mutex
[2003/09/25 23:03:09, 10] libsmb/clikrb5.c:get_krb5_smb_session_key(385)
 Got KRB5 session key of length 8
...

[2003/09/25 23:03:09, 3] smbd/sesssetup.c:reply_spnego_kerberos(178)
 Ticket name is [EMAIL PROTECTED]
[2003/09/25 23:03:09, 5] lib/username.c:Get_Pwnam(288)
 Finding user MYDOMAIN.COM\Thatsme
[2003/09/25 23:03:09, 5] lib/username.c:Get_Pwnam_internals(223)
 Trying _Get_Pwnam(), username as lowercase is mydomain.com\thatsme
..and uppercase, and combinations, with and without the domain name 
appended..

[2003/09/25 23:03:10, 1] smbd/sesssetup.c

[Samba] get file information from smb share

2003-08-18 Thread Razvan Cosma
  Hello,
 I (and probably everyone else) noticed that right-clicking on a file 
located on a remote share (at least in the windows explorer) provides a 
lot of useful info besides the size & access rights. It does that 
without transferring the entire file, so what I'm wondering if there is 
a way to access that info using libsmbclient (meaning: is this part of 
the smb/cifs protocol specification or just a explorer feature)?

 Regards,
Razvan Cosma
--
To unsubscribe from this list go to the following URL and read the
instructions:  http://lists.samba.org/mailman/listinfo/samba


RE: [Samba] Samba 3b3 + ADS

2003-07-31 Thread Razvan Cosma
> I've been trying for a couple of days to get ADS support built into
> Samba 3.  I've been searching the archives for something that will
help
> me out, but nothing seems to work.
> 
> Here's what I've tried, first on FreeBSD 4.8:
> 
> FreeBSD 4.8
> Samba 3b3, ./configure --with-ads --with-krb5=/usr (I installed FBSD
> krb5 from /usr/src/kerberos5) works like a charm.  make works and I
see
> all the fancy ads stuff fly by the screen like it's compiling.  I then
> test source/bin/net ads - "ADS support not compiled in".
> 
Same problem here.. linux slackware. Is it necessary to also have the
ldap libraries installed?

--
To unsubscribe from this list go to the following URL and read the
instructions:  http://lists.samba.org/mailman/listinfo/samba


[Samba] samba 3 active directory

2003-07-31 Thread Razvan Cosma
  Hello,

 I'm posting this only in the event somebody else does a search in the
mlist archive for such keywords (I know I did), hope you won't mind. 
Status: IT WORKS! :)
 Steps taken:
Install Slackware (well, that was already in place). 
Install PAM (Linux-PAM-0.77, plain ./configure) - this I will need later
for Postfix SMTP auth against AD. 
Install Kerberos (krb5-1.2.8, ./configure --prefix=/usr/local/kerberos 
--without-krb4 --enable-dns --enable-dns-for-kdc --enable-dns-for-realm 
--enable-shared). 
Install OpenLDAP (openldap-2.1.22, ./configure --disable-slapd
--disable-slurpd). 
Install Samba (samba-3.0.0beta3, ./configure --prefix=/usr/local/samba 
--with-smbwrapper --with-dce-dfs --with-ads --with-smbmount --with-pam
--with-libsmbclient --with-acl-support --with-winbind 
--with-krb5=/usr/local/kerberos --without-quotas --with-ldap)

joe /etc/krb5.conf
[realms]
 DOM.AIN = {
  kdc = DC.DOM.AIN
 }
test with 
kinit [EMAIL PROTECTED]

joe /usr/local/samba/lib/smb.conf
[global]
security = ADS
realm = DOM.AIN
winbind use default domain = yes
wins server = dc.dom.ain
encrypt passwords = yes
password server = dc.dom.ain

net ads join  -U Administrator
nmbd -D
smbd -D
winbindd

..that's all I think

PS. Thanks to the Samba team for the great work

--
To unsubscribe from this list go to the following URL and read the
instructions:  http://lists.samba.org/mailman/listinfo/samba


[Samba] ADS authentication.. almost works

2003-07-28 Thread Razvan Cosma
  Hello,

 Beta 3, ./configure --with-ads & krb5, slackware system (no PAM). 
Things seem to be correctly configured, done the net join part without 
errors, I can use e.g. smbclient -L or wbinfo -u, but users cannot acces 
 shares on the Samba machine. Snip from the log (trying to connect from 
the domain controller on which I'm logged as administrator):

[2003/07/28 14:52:27, 3] auth/auth.c:check_ntlm_password(216)
  check_ntlm_password:  Checking password for unmapped user 
[EMAIL PROTECTED] with the new password interface
[2003/07/28 14:52:27, 3] auth/auth.c:check_ntlm_password(219)
  check_ntlm_password:  mapped user is: 
[EMAIL PROTECTED]
[2003/07/28 14:52:27, 3] smbd/sec_ctx.c:push_sec_ctx(256)
  push_sec_ctx(0, 0) : sec_ctx_stack_ndx = 1
[2003/07/28 14:52:27, 3] smbd/uid.c:push_conn_ctx(287)
  push_conn_ctx(0) : conn_ctx_stack_ndx = 0
[2003/07/28 14:52:27, 3] smbd/sec_ctx.c:set_sec_ctx(288)
  setting sec ctx (0, 0) - sec_ctx_stack_ndx = 1
[2003/07/28 14:52:27, 0] passdb/pdb_smbpasswd.c:startsmbfilepwent(182)
  startsmbfilepwent_internal: unable to open file 
/usr/local/samba/private/smbpasswd. Error was No such file or directory
[2003/07/28 14:52:27, 0] passdb/pdb_smbpasswd.c:smbpasswd_getsampwnam(1284)
  Unable to open passdb database.
[2003/07/28 14:52:27, 3] smbd/sec_ctx.c:pop_sec_ctx(386)
  pop_sec_ctx (0, 0) - sec_ctx_stack_ndx = 0
[2003/07/28 14:52:27, 3] auth/auth_sam.c:check_sam_security(439)
  Couldn't find user 'Administrator' in passdb file.
[2003/07/28 14:52:27, 2] auth/auth.c:check_ntlm_password(309)
  check_ntlm_password:  Authentication for user [Administrator] -> 
[Administrator] FAILED with error NT_STATUS_NO_SUCH_USER
[2003/07/28 14:52:27, 3] smbd/process.c:process_smb(878)
  Transaction 3 of length 214
[2003/07/28 14:52:27, 3] smbd/process.c:switch_message(673)
  switch message SMBsesssetupX (pid 14296)
[2003/07/28 14:52:27, 3] smbd/sec_ctx.c:set_sec_ctx(288)
  setting sec ctx (0, 0) - sec_ctx_stack_ndx = 0
[2003/07/28 14:52:27, 3] smbd/sesssetup.c:reply_sesssetup_and_X(551)
  wct=12 flg2=0xc807
[2003/07/28 14:52:27, 2] smbd/sesssetup.c:setup_new_vc_session(507)
  setup_new_vc_session: New VC == 0, if NT4.x compatible we would close 
all old resources.
[2003/07/28 14:52:27, 3] smbd/sesssetup.c:reply_sesssetup_and_X_spnego(448)
  Doing spnego session setup
[2003/07/28 14:52:27, 3] smbd/sesssetup.c:reply_sesssetup_and_X_spnego(472)
  NativeOS=[Windows 2000 2195] NativeLanMan=[Windows 2000 5.0]
[2003/07/28 14:52:27, 3] smbd/sesssetup.c:reply_spnego_negotiate(353)
  Got OID 1 3 6 1 4 1 311 2 2 10
[2003/07/28 14:52:27, 3] smbd/sesssetup.c:reply_spnego_negotiate(360)
  Got secblob of size 44
[2003/07/28 14:52:27, 3] libsmb/ntlmssp.c:debug_ntlmssp_flags(33)
  Got NTLMSSP neg_flags=0xe008b297
[2003/07/28 14:52:27, 3] smbd/process.c:process_smb(878)
  Transaction 4 of length 310
[2003/07/28 14:52:27, 3] smbd/process.c:switch_message(673)
  switch message SMBsesssetupX (pid 14296)
[2003/07/28 14:52:27, 3] smbd/sec_ctx.c:set_sec_ctx(288)
  setting sec ctx (0, 0) - sec_ctx_stack_ndx = 0
[2003/07/28 14:52:27, 3] smbd/sesssetup.c:reply_sesssetup_and_X(551)
  wct=12 flg2=0xc807
[2003/07/28 14:52:27, 2] smbd/sesssetup.c:setup_new_vc_session(507)
  setup_new_vc_session: New VC == 0, if NT4.x compatible we would close 
all old resources.
[2003/07/28 14:52:27, 3] smbd/sesssetup.c:reply_sesssetup_and_X_spnego(448)
  Doing spnego session setup
[2003/07/28 14:52:27, 3] smbd/sesssetup.c:reply_sesssetup_and_X_spnego(472)
  NativeOS=[Windows 2000 2195] NativeLanMan=[Windows 2000 5.0]
[2003/07/28 14:52:27, 3] libsmb/ntlmssp.c:ntlmssp_server_auth(283)
  Got user=[Administrator] domain=[DOMAIN] workstation=[DOMAINCTL] 
len1=24 len2=24
[2003/07/28 14:52:27, 3] auth/auth.c:check_ntlm_password(216)
  check_ntlm_password:  Checking password for unmapped user 
[EMAIL PROTECTED] with the new password interface
[2003/07/28 14:52:27, 3] auth/auth.c:check_ntlm_password(219)
  check_ntlm_password:  mapped user is: 
[EMAIL PROTECTED]
[2003/07/28 14:52:27, 3] smbd/sec_ctx.c:push_sec_ctx(256)
  push_sec_ctx(0, 0) : sec_ctx_stack_ndx = 1
[2003/07/28 14:52:27, 3] smbd/uid.c:push_conn_ctx(287)
  push_conn_ctx(0) : conn_ctx_stack_ndx = 0
[2003/07/28 14:52:27, 3] smbd/sec_ctx.c:set_sec_ctx(288)
  setting sec ctx (0, 0) - sec_ctx_stack_ndx = 1
[2003/07/28 14:52:27, 0] passdb/pdb_smbpasswd.c:startsmbfilepwent(182)
  startsmbfilepwent_internal: unable to open file 
/usr/local/samba/private/smbpasswd. Error was No such file or directory
[2003/07/28 14:52:27, 0] passdb/pdb_smbpasswd.c:smbpasswd_getsampwnam(1284)
  Unable to open passdb database.
[2003/07/28 14:52:27, 3] smbd/sec_ctx.c:pop_sec_ctx(386)
  pop_sec_ctx (0, 0) - sec_ctx_stack_ndx = 0
[2003/07/28 14:52:27, 3] auth/auth_sam.c:check_sam_security(439)
  Couldn't find user 'Administrator' in passdb file.
[2003/07/28 14:52:27, 2] auth/auth.c:check_ntlm_password(309)
  check_ntlm_password:  Authentication for user [Administrator] -> 
[Administrator] FAILED with error NT_STAT

[Samba] security=user with windows clients

2002-12-13 Thread Razvan
Hi,

I hate to stress you guys, i already posted a few messages about this but
i am still confused about what's going on. Windows (here XP but i think
others as well) is unable to see my list of shares when i have
security=user! how come? how can i fix this?

Thanks angain,
Razvan Rotaru


-- 
To unsubscribe from this list go to the following URL and read the
instructions:  http://lists.samba.org/mailman/listinfo/samba



[Samba] libsmbclient init error

2002-12-12 Thread Razvan
Hi,

I'm trying to use libsmbclient that comes with samba (2.2.7). Even if i
take testsmbc.c that comes with samba (as an example program for
libsmbclient) I get an "No such file or directory" error. Where is the
problem? I though it might be that it cannot find smb.conf, but i don't
know how to fix this.

Thanks



-- 
To unsubscribe from this list go to the following URL and read the
instructions:  http://lists.samba.org/mailman/listinfo/samba



[Samba] authentication problem with winXP

2002-12-09 Thread Razvan
Hi,

Here is my situation. I share several directories as public, and some
other that must be read-write but with authentication (it does not matter
is the client supplies the username or not, although it would be nice, but
the password is essential as not everybody must have write permission).
So what i first did was use the server with "security=user". WindowsXp
does not see my shares with this options set. It does not even ask for a
username and a password authentication (as it should just like when guest
account is disabled in XP). So then i went on putting "security=share" and
specifying in each non-public share :
public=no
writeable=yes
username=user ; for cases in which the client does not supply the
  ; username, but only the password
I also noticed i have to turn password encryption off in order to connect
to such shares with smbclient from linux. Still with encryption or not,
Windows XP refuses to connect to my share. What really drives me mad is
that (Windows Explorer) does not ask for a username/password but instead
asks anly for a password and connects with "MACHINENAME\Guest". I can
connect from smbclient with any user as long i supply the correct
password, from windows . no chance... :(
Where is the problem? I just want to share something with some sort of
authentication? Anybody got better or maybe simpler ideas?
I attached my smb.conf file in case somebody has the patience to take a
look. I'd really appreciate it. "E$" is the problem share.

So to put it simpler:
1)Why does windows not see my public shares when security=user
2)How can i share something and protect it with some sort of
authentication (and it should be accesible from Windows XP)

Thanks for reading my mail.

Razvan Rotaru


# This is the main Samba configuration file. You should read the
# smb.conf(5) manual page in order to understand the options listed
# here. Samba has a huge number of configurable options (perhaps too
# many!) most of which are not shown in this example
#
# Any line which starts with a ; (semi-colon) or a # (hash) 
# is a comment and is ignored. In this example we will use a #
# for commentry and a ; for parts of the config file that you
# may wish to enable
#
# NOTE: Whenever you modify this file you should run the command "testparm"
# to check that you have not made any basic syntactic errors. 
#
#=== Global Settings =
[global]

# 1. Server Naming Options:
# workgroup = NT-Domain-Name or Workgroup-Name
   workgroup = P22

# netbios name is the name you will see in "Network Neighbourhood",
# but defaults to your hostname
;  netbios name = 

# server string is the equivalent of the NT Description field
   server string = de pe plaiurile de vanatoare vesnice...

# Message command is run by samba when a "popup" message is sent to it.
# The example below is for use with LinPopUp:
; message command = /usr/bin/linpopup "%f" "%m" %s; rm %s

# 2. Printing Options:
# CHANGES TO ENABLE PRINTING ON ALL CUPS PRINTERS IN THE NETWORK
# (as cups is now used in linux-mandrake 7.2 by default)
# if you want to automatically load your printer list rather
# than setting them up individually then you'll need this
   printcap name = lpstat
   load printers = no

# It should not be necessary to spell out the print system type unless
# yours is non-standard. Currently supported print systems include:
# bsd, sysv, plp, lprng, aix, hpux, qnx, cups
   printing = cups

# Samba 2.2 supports the Windows NT-style point-and-print feature. To
# use this, you need to be able to upload print drivers to the samba
# server. The printer admins (or root) may install drivers onto samba.
# Note that this feature uses the print$ share, so you will need to 
# enable it below.
# This parameter works like domain admin group:
# printer admin = @ 
;   printer admin = @adm

# 3. Logging Options:
# this tells Samba to use a separate log file for each machine
# that connects
   log file = /var/log/samba/log.%m

# Put a capping on the size of the log files (in Kb).
   max log size = 50

# Set the log (verbosity) level (0 <= log level <= 10)
; log level = 3

# 4. Security and Domain Membership Options:
# This option is important for security. It allows you to restrict
# connections to machines which are on your local network. The
# following example restricts access to two C class networks and
# the "loopback" interface. For more examples of the syntax see
# the smb.conf man page. Do not enable this if (tcp/ip) name resolution does
# not work for all the hosts in your network.
;   hosts allow = 192.168.1. 192.168.2. 127.

# Uncomment this if you want a guest account, you must add this to /etc/passwd
# otherwise the user "nobody" is used
;  guest account = pcguest

# Security mode.

[Samba] problem with smbc_init in libsmbclient

2002-11-28 Thread Razvan
Hi,

I have attached a very simple c program, that first does a smbc_init and
then a smbc_opendir. The problem: smbc_init return an error (No such file
or directory) and then i get a segmentation fault. I don't know what
possibly could be the problem. Maybe some of you guys have an idea. I
think i have libsmbclient from samba 2.2.7(compiled on my own system) and
the rest of the samba stuff is the one that comes with mandrake 8.2. 

Thanks,
Razvan Rotaru



/* 
   Unix SMB/Netbios implementation.
   Version 2.0
   SMB client library test program
   Copyright (C) Andrew Tridgell 1998
   Copyright (C) Richard Sharpe 2000
   Copyright (C) John Terpsra 2000
   
   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 
#include 
#include 
#include 
#include 


void auth_fn(const char *server, const char *share,
 char *workgroup, int wgmaxlen, char *username, int unmaxlen,
 char *password, int pwmaxlen)
{
  char temp[128];

  fprintf(stdout, "Need password for //%s/%s\n", server, share);

  fprintf(stdout, "Enter workgroup: [%s] ", workgroup);
  fgets(temp, sizeof(temp), stdin);

  if (temp[strlen(temp) - 1] == 0x0a) /* A new line? */
temp[strlen(temp) - 1] = 0x00;

  if (temp[0]) strncpy(workgroup, temp, wgmaxlen - 1);

  fprintf(stdout, "Enter username: [%s] ", username);
  fgets(temp, sizeof(temp), stdin);

  if (temp[strlen(temp) - 1] == 0x0a) /* A new line? */
temp[strlen(temp) - 1] = 0x00;

  if (temp[0]) strncpy(username, temp, unmaxlen - 1);

  fprintf(stdout, "Enter password: [%s] ", password);
  fgets(temp, sizeof(temp), stdin);

  if (temp[strlen(temp) - 1] == 0x0a) /* A new line? */
temp[strlen(temp) - 1] = 0x00;

  if (temp[0]) strncpy(password, temp, pwmaxlen - 1);

}



int main(int argc, char *argv[])
{
int err, fd, dh;
//char dirbuf[512];
//char *dirp;
struct stat st1, st2;
struct smbc_dirent dirp[128];
char path[]="smb://cherban/";


err = smbc_init(auth_fn,  10);
if (err < 0) {
fprintf(stderr, "Initializing the smbclient library : %s\n", strerror(errno));
}


dh=smbc_opendir(path);
if (dh <0) {
fprintf(stderr, "Could not open directory: %s: %s\n",path,strerror(errno));
exit(1);
}


/* Now, list those directories, but in funny ways ... */

/*if ((dirc = smbc_getdents(dh1,dirp,sizeof(struct smbc_dirent)*128)) < 0) {

  fprintf(stderr, "Problems getting directory entries: %s\n",
  strerror(errno));

  exit(1);

}
*/
/* Now, process the list of names ... */

/*fprintf(stdout, "Directory listing, size = %u\n", dirc);

while (dirc > 0) {

  dsize = ((struct smbc_dirent *)dirp)->dirlen;
  fprintf(stdout, "Dir Ent, Type: %u, Name: %s, Comment: %s\n",
  ((struct smbc_dirent *)dirp)->smbc_type, 
  ((struct smbc_dirent *)dirp)->name, 
  ((struct smbc_dirent *)dirp)->comment);

  dirp += dsize;
  (char *)dirc -= dsize;

}

*/
  return 0;
}



[Samba] c++ with libsmbclient

2002-11-27 Thread Razvan
Hi,

What i want is to write a code that scans the network for hosts and
shares. I figured the shared library libsmbclient from samba is just what
i need. Problem: a cannot compile my program in c++, only in c. When i
change the extension of my source file from .c to .cpp (i use gcc, or
g++) i get linker errors:

[roti@manitu lyta]$ gcc -lsmbclient scan.cpp
/tmp/ccD9lo2a.o: In function `main':
/tmp/ccD9lo2a.o(.text+0x234): undefined reference to `smbc_init(void
(*)(char const *, char const *, char *, int, char *, int, char *, int),
int)'
/tmp/ccD9lo2a.o(.text+0x249): undefined reference to `smbc_opendir(char
const *)'
/tmp/ccD9lo2a.o(.text+0x2b3): undefined reference to
`smbc_getdents(unsigned int, smbc_dirent *, int)'
collect2: ld returned 1 exit status

I installed libsmbclient.so in a different way. I already have samba (on
Mandrake 8.2) but libsmbclient was not there, so i downloaded the source
code, ./configure'd it, make bin/libsmbclient.so'd it,copied
libsmbclient.so to /usr/bin and runned ldconfig. Still the library works
but only in c++. Why?

-- 
To unsubscribe from this list go to the following URL and read the
instructions:  http://lists.samba.org/mailman/listinfo/samba