1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-25 23:21:54 +03:00
Commit Graph

143 Commits

Author SHA1 Message Date
Andreas Schneider
71b40127e1 s3:lib: Fix code spelling
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Martin Schwenke <mschwenke@ddn.com>
2023-07-13 05:41:36 +00:00
Volker Lendecke
7870e82cb4 lib: Fix whitespace
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2022-12-14 04:32:34 +00:00
Volker Lendecke
8cc0489c80 lib: Add get_current_user_info_domain()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2022-12-12 21:16:33 +00:00
Volker Lendecke
46ce8a4710 lib: Make substitute.c's "remote_proto" static
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2022-12-12 21:16:33 +00:00
Ralph Boehme
25043ebb2e source3: move lib/substitute.c functions out of proto.h
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14897

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2021-11-11 13:49:32 +00:00
Andreas Schneider
622e84cfca s3:lib: Remove NIS support from substitute
%N is often used to get the netbios name (local machine name). So we
need to keep it.

This is covered by samba.tests.s3passdb.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2021-04-22 17:57:30 +00:00
Matthew DeVore
c2ac923c6a s3: safe_string: do not include string_wrappers.h
Rather than have safe_string.h #include string_wrappers.h, make users of
string_wrappers.h include it explicitly.

includes.h now no longer includes string_wrappers.h transitively. Still
allow includes.h to #include safe_string.h for now so that as many
modules as possible get the safety checks in it.

Signed-off-by: Matthew DeVore <matvore@google.com>
Reviewed-by: David Mulder <dmulder@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-08-28 00:56:34 +00:00
Jeremy Allison
859a86b37e s3: lib: Now remote_machine is static, we can depend on it being non-NULL.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Fri Feb  7 18:26:15 UTC 2020 on sn-devel-184
2020-02-07 18:26:15 +00:00
Andreas Schneider
daaf550e19 s3:lib: Use a static buffer for (local|remote)_machine
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-02-07 17:00:42 +00:00
Ralph Boehme
8bfa0d5867 s3/lib: RIP smb_user_name
This has been replaced in previous commits by consistently using
current_user_info.smb_name.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2020-02-06 10:17:44 +00:00
Ralph Boehme
f8e218acd3 s3/lib: use talloc_alpha_strcpy() in sub_set_smb_name()
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2020-02-06 10:17:43 +00:00
Ralph Boehme
e3cd8e46b3 s3/lib: use talloc_alpha_strcpy() in set_remote_machine_name()
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2020-02-06 10:17:43 +00:00
Ralph Boehme
1a8e6271c6 s3/lib: use talloc_alpha_strcpy() in set_local_machine_name()
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2020-02-06 10:17:43 +00:00
Stefan Metzmacher
848cd4c460 s3:lib: remove unused str_list_sub_basic()
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2019-11-27 10:25:31 +00:00
Ralph Boehme
41ab92b62f s3:lib: factor out talloc_sub_advanced() from talloc_sub_full()
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13745

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2019-11-07 14:16:42 +00:00
Ralph Boehme
4736623c24 s3: rename talloc_sub_advanced() to talloc_sub_full()
We currently have the following substitution functions:

  talloc_sub_basic()
  talloc_sub_advanced()

talloc_sub_basic() currently substitutes a subset of talloc_sub_advanced().

We'll need a function X that only substitutes what talloc_sub_advanced()
substitutes *without* what talloc_sub_basic() does.

To get there rename talloc_sub_advanced() to talloc_sub_full(). A subsequent
commit will then bring back talloc_sub_advanced() as described above.

Examples with fictional replacement letters A and B. Currently:

  talloc_sub_basic:    A
  talloc_sub_advanced: AB

New:

  talloc_sub_basic:    A
  talloc_sub_advanced:  B
  talloc_sub_full:     AB

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13745

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2019-11-07 14:16:41 +00:00
Ralph Boehme
a591de2865 s3: remove unused function standard_sub_advanced()
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13745

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2019-11-07 14:16:41 +00:00
Noel Power
80f5461ae6 s3/lib: clang: Fix 'Value stored to 'b' is never read'
Fixes:

source3/lib/substitute.c:516:7: warning: Value stored to 'b' is never read <--[clang]
        for (b = s = a_string; (p = strchr_m(s, '%')); s = a_string + (p - b)) {
             ^   ~~~~~~~~~~~~
source3/lib/substitute.c:709:7: warning: Value stored to 'b' is never read <--[clang]
        for (b = s = a_string; (p = strchr_m(s, '%')); s = a_string + (p - b)) {
             ^   ~~~~~~~~~~~~
source3/lib/substitute.c:811:7: warning: Value stored to 'b' is never read <--[clang]
        for (b = s = a_string; (p = strchr_m(s, '%')); s = a_string + (p - b)) {
             ^   ~~~~~~~~~~~~
3 warnings generated.

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
2019-07-16 22:52:24 +00:00
Stefan Metzmacher
df5e459299 s3:lib: add caching to set_current_user_info()
Currently we do that in the caller, but we use global
cache anyway, so we can simplify the callers.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2018-06-18 08:59:15 +02:00
Dr. Thomas Orgis
ca66efc241 Add substitutions %t, %j, and %J as path-safe variants of %T, %i, and %I.
Rationale: Using the existing substitutions in construction of paths
(dynamic shares, created on client connect) results in directory names with
colons and dots in them. Those can be hard to use when accessed from a
different share, as Windows does not allow : in paths and has some ideas about
dots.

Signed-off-by: Dr. Thomas Orgis <thomas.orgis@uni-hamburg.de>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
2018-01-08 03:34:17 +01:00
Volker Lendecke
6ec81ca3c1 lib: Fix CID 1373623 Dereference after null check
We should not overload "p", this is used in the outer loop

BUG: https://bugzilla.samba.org/show_bug.cgi?id=12276
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Böhme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2016-10-12 20:54:08 +02:00
Andreas Schneider
619ca5f63c s3-lib: Fix %G substitution in AD member environment
If we are a domain member we should look up the user with the domain
name specified else it will only work if we have
'winbind use default domain' set.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=12276

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2016-10-07 12:09:09 +02:00
Michael Adam
6147ed70ff s3:lib: fix a typo in comment for talloc_sub_basic()
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>

Autobuild-User(master): Michael Adam <obnox@samba.org>
Autobuild-Date(master): Thu Aug  4 22:08:35 CEST 2016 on sn-devel-144
2016-08-04 22:08:35 +02:00
Michael Adam
ef269c9ddc substitute: Fix talloc_sub_basic for %G in the case of a local user.
This fixes a regression introduced by the fix for bug 10286.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=10286

Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Fri Jan 22 05:03:25 CET 2016 on sn-devel-144
2016-01-22 05:03:25 +01:00
Garming Sam
a3979677a8 param: rename lp function and variable from "nis_home_map" to "nis_homedir"
Signed-off-by: Garming Sam <garming@catalyst.net.nz>

Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Sat Feb  8 03:31:34 CET 2014 on sn-devel-104
2014-02-08 03:31:34 +01:00
Andreas Schneider
8eef4ab79e s3-lib: Fix %G substitution for domain users in smbd
BUG: https://bugzilla.samba.org/show_bug.cgi?id=10286
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Christian Ambach <ambi@samba.org>

Autobuild-User(master): Christian Ambach <ambi@samba.org>
Autobuild-Date(master): Tue Dec 10 16:39:43 CET 2013 on sn-devel-104
2013-12-10 16:39:43 +01:00
Andreas Schneider
6366ebb79b s3-lib: Add grpname to talloc_sub_specified().
BUG: https://bugzilla.samba.org/show_bug.cgi?id=2191

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2013-11-21 15:00:44 -08:00
Jeremy Allison
b70f23c2b5 Correctly check for errors in strlower_m() returns. 2012-08-09 12:08:18 -07:00
Jelmer Vernooij
c0288e0612 lib/util: Remove obsolete sys_getpid() and sys_fork().
The performance of these is minimal (these days) and they can return
invalid results when used as part of applications that do not use
sys_fork().

Autobuild-User: Jelmer Vernooij <jelmer@samba.org>
Autobuild-Date: Sat Mar 24 21:55:41 CET 2012 on sn-devel-104
2012-03-24 21:55:40 +01:00
Andrew Bartlett
b190e3cd79 s3-lib: Remove unused standard_sub_conn() 2012-02-17 12:19:29 +01:00
Jeremy Allison
a9e03337c1 Finally remove all malloc()'s from the substitute code. Now totally
talloc() based.

Autobuild-User: Jeremy Allison <jra@samba.org>
Autobuild-Date: Fri Jan 27 03:43:21 CET 2012 on sn-devel-104
2012-01-27 03:43:21 +01:00
Jeremy Allison
17a77ea9b4 Fix a really slow memory leak (in master at least). Found by Ira Cooper <ira@wakeful.net>.
Bug #8724 - Memory leak in parent smbd on connection.

Autobuild-User: Jeremy Allison <jra@samba.org>
Autobuild-Date: Fri Jan 27 01:26:28 CET 2012 on sn-devel-104
2012-01-27 01:26:28 +01:00
Andrew Bartlett
9289537993 s3-auth Use struct auth_user_info_unix for unix_name and sanitized_username
This is closer to the layout of struct auth_session_info in auth.idl

Andrew Bartlett

Signed-off-by: Andrew Tridgell <tridge@samba.org>
2011-07-20 09:17:11 +10:00
Andrew Bartlett
6d741e918f s3-auth Use *unix_token rather than utok in struct auth3_session_info
This brings this structure one step closer to the struct auth_session_info.

A few SMB_ASSERT calls are added in some key places to ensure that
this pointer is initialised, to make tracing any bugs here easier in
future.

NOTE: Many of the users of this structure should be reviewed, as unix
and NT access checks are mixed in a way that should just be done using
the NT ACL.  This patch has not changed this behaviour however.

Andrew Bartlett

Signed-off-by: Andrew Tridgell <tridge@samba.org>
2011-07-20 09:17:10 +10:00
Andrew Bartlett
b332743ddb s3-param Remove %(DomainSID) support
This also removes the now unused longvar support.  This experiment
never took off.

Fixing this allows me to resolve the the library loop between libsmbconf
and SECRETS3/passdb.

Andreas correctly points out that this loop originally comes from my
patch to obtain the domain sid from passdb
(25cfa29e29), but as I would prefer to
keep that feature, I'm hoping to break the loop here instead.

Andrew Bartlett
2011-06-24 03:52:05 +02:00
Andrew Bartlett
74eed8f3ed s3-param Remove special case for global_myname(), rename to lp_netbios_name()
There is no reason this can't be a normal constant string in the
loadparm system, now that we have lp_set_cmdline() to handle overrides
correctly.

Andrew Bartlett
2011-06-09 12:40:09 +02:00
Andrew Bartlett
3b7e1ac31c s3-lib Move realloc based string substitution functions out of util_str.c
This makes the dependency set for source3/lib/util_str.c simpiler,
which in turn makes it easier to build a dependency tree.

Andrew Bartlett
2011-05-31 00:32:08 +02:00
Andrew Bartlett
da662b82b8 s3-lib Replace StrnCaseCmp() with strncasecmp_m()
strncasecmp_m() never needs to call to talloc, and via next_codepoint()
still has an ASCII fast-path bypassing iconv() calls.

Andrew Bartlett
2011-05-18 16:12:08 +02:00
Günther Deschner
7e73214ebf s3-auth: use auth.h where needed.
Guenther
2011-03-30 01:13:09 +02:00
Günther Deschner
49fcf653b1 s3-includes: only include system/passwd.h when needed.
Guenther
2011-03-30 01:13:07 +02:00
Andrew Bartlett
2e69e89456 s3-auth Rename auth_serversupplied_info varaiables: server_info -> session_info
These variables, of type struct auth_serversupplied_info were poorly
named when added into 2001, and in good consistant practice, this has
extended all over the codebase in the years since.

The structure is also not ideal for it's current purpose.  Originally
intended to convey the results of the authentication modules, it
really describes all the essential attributes of a session.  This
rename will reduce the volume of a future patch to replaced these with
a struct auth_session_info, with auth_serversupplied_info confined to
the lower levels of the auth subsystem, and then eliminated.

(The new structure will be the output of create_local_token(), and the
change in struct definition will ensure that this is always run, populating
local groups and privileges).

Andrew Bartlett

Signed-off-by: Stefan Metzmacher <metze@samba.org>
2011-02-22 16:20:10 +11:00
Volker Lendecke
4a58c640cc s3: Set the client_id in substitute.c once
This never changes during a client connection's life, so we can set it
once.
2010-08-29 21:55:23 +02:00
Volker Lendecke
15d0d9bcfb s3: Fix a (highly unlikly) memleak in set_local_machine_name() 2010-08-28 14:15:45 +02:00
Volker Lendecke
755ef5cf11 s3: Remove smbd_server_fd() from set_local_machine_name() 2010-08-28 14:06:10 +02:00
Volker Lendecke
96ae457023 s3: Remove get_client_fd() 2010-08-16 13:13:10 +02:00
Günther Deschner
c136b84f0d s3-secrets: only include secrets.h when needed.
Guenther
2010-08-05 10:12:25 +02:00
Andrew Bartlett
cba7f8b827 s3:dom_sid Global replace of DOM_SID with struct dom_sid
This matches the structure that new code is being written to,
and removes one more of the old-style named structures, and
the need to know that is is just an alias for struct dom_sid.

Andrew Bartlett

Signed-off-by: Günther Deschner <gd@samba.org>
2010-05-21 10:39:59 +02:00
Volker Lendecke
cf2febf3d1 s3: Make alloc_sub_basic() static 2009-11-21 20:54:10 +01:00
Volker Lendecke
b79bcd972c s3: Fix some nonempty blank lines 2009-11-21 20:49:16 +01:00
Andrew Bartlett
3b3e21bd9b Convert Samba3 to use the common lib/util/charset API
This removes calls to push_*_allocate() and pull_*_allocate(), as well
as convert_string_allocate, as they are not in the common API

To allow transition to a common charcnv in future, provide Samba4-like
strupper functions in source3/lib/charcnv.c

(the actual implementation remains distinct, but the API is now shared)

Andrew Bartlett
2009-04-14 12:53:56 +10:00