summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2005-03-23 23:26:33 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 10:56:15 -0500
commit5d1cb8e79edea9e8581d3c2c9dd297310cd9a98c (patch)
tree12142ce30c28b602882cb6c3492dfc5811a7eace /source3/lib
parent920745f0df024741f28e8557c52187a8db01c5d1 (diff)
downloadsamba-5d1cb8e79edea9e8581d3c2c9dd297310cd9a98c.tar.gz
samba-5d1cb8e79edea9e8581d3c2c9dd297310cd9a98c.tar.bz2
samba-5d1cb8e79edea9e8581d3c2c9dd297310cd9a98c.zip
r6014: rather large change set....
pulling back all recent rpc changes from trunk into 3.0. I've tested a compile and so don't think I've missed any files. But if so, just mail me and I'll clean backup in a couple of hours. Changes include \winreg, \eventlog, \svcctl, and general parse_misc.c updates. I am planning on bracketing the event code with an #ifdef ENABLE_EVENTLOG until I finish merging Marcin's changes (very soon). (This used to be commit 4e0ac63c36527cd8c52ef720cae17e84f67e7221)
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/talloc.c13
-rw-r--r--source3/lib/time.c22
-rw-r--r--source3/lib/util.c4
-rw-r--r--source3/lib/util_seaccess.c39
-rw-r--r--source3/lib/util_str.c14
-rw-r--r--source3/lib/util_unistr.c25
6 files changed, 105 insertions, 12 deletions
diff --git a/source3/lib/talloc.c b/source3/lib/talloc.c
index cafe065479..f5e21299b5 100644
--- a/source3/lib/talloc.c
+++ b/source3/lib/talloc.c
@@ -338,6 +338,19 @@ char *talloc_strdup(TALLOC_CTX *t, const char *p)
return NULL;
}
+/* strndup with a talloc */
+char *talloc_strndup(TALLOC_CTX *mem_ctx, const char *str, size_t maxlen)
+{
+ size_t len = strnlen(str, maxlen);
+ void *ret = TALLOC(mem_ctx, len+1);
+
+ if (ret != NULL) {
+ memcpy(ret, str, len);
+ ((char *)ret)[len] = '\0';
+ }
+ return ret;
+}
+
/** strdup_upper with a talloc */
char *talloc_strdup_upper(TALLOC_CTX *t, const char *p)
{
diff --git a/source3/lib/time.c b/source3/lib/time.c
index 84004a099b..9f94791b58 100644
--- a/source3/lib/time.c
+++ b/source3/lib/time.c
@@ -791,3 +791,25 @@ SMB_BIG_INT usec_time_diff(struct timeval *larget, struct timeval *smallt)
SMB_BIG_INT sec_diff = larget->tv_sec - smallt->tv_sec;
return (sec_diff * 1000000) + (SMB_BIG_INT)(larget->tv_usec - smallt->tv_usec);
}
+
+
+/****************************************************************************
+ convert ASN.1 GeneralizedTime string to unix-time
+ returns 0 on failure; Currently ignores timezone.
+****************************************************************************/
+time_t generalized_to_unix_time(const char *str)
+{
+ struct tm tm;
+
+ ZERO_STRUCT(tm);
+
+ if (sscanf(str, "%4d%2d%2d%2d%2d%2d",
+ &tm.tm_year, &tm.tm_mon, &tm.tm_mday,
+ &tm.tm_hour, &tm.tm_min, &tm.tm_sec) != 6) {
+ return 0;
+ }
+ tm.tm_year -= 1900;
+ tm.tm_mon -= 1;
+
+ return timegm(&tm);
+}
diff --git a/source3/lib/util.c b/source3/lib/util.c
index 42ead313a9..8db7bb38ab 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -2172,8 +2172,12 @@ BOOL reg_split_key(const char *full_keyname, uint32 *reg_type, char *key_name)
if (strequal(tmp, "HKLM") || strequal(tmp, "HKEY_LOCAL_MACHINE"))
(*reg_type) = HKEY_LOCAL_MACHINE;
+ else if (strequal(tmp, "HKCR") || strequal(tmp, "HKEY_CLASSES_ROOT"))
+ (*reg_type) = HKEY_CLASSES_ROOT;
else if (strequal(tmp, "HKU") || strequal(tmp, "HKEY_USERS"))
(*reg_type) = HKEY_USERS;
+ else if (strequal(tmp, "HKPD")||strequal(tmp, "HKEY_PERFORMANCE_DATA"))
+ (*reg_type) = HKEY_PERFORMANCE_DATA;
else {
DEBUG(10,("reg_split_key: unrecognised hive key %s\n", tmp));
return False;
diff --git a/source3/lib/util_seaccess.c b/source3/lib/util_seaccess.c
index b5a9010b5c..cb0f46e2f9 100644
--- a/source3/lib/util_seaccess.c
+++ b/source3/lib/util_seaccess.c
@@ -316,3 +316,42 @@ BOOL se_access_check(const SEC_DESC *sd, const NT_USER_TOKEN *token,
return False;
}
+
+/*******************************************************************
+ samr_make_sam_obj_sd
+ ********************************************************************/
+
+NTSTATUS samr_make_sam_obj_sd(TALLOC_CTX *ctx, SEC_DESC **psd, size_t *sd_size)
+{
+ extern DOM_SID global_sid_World;
+ DOM_SID adm_sid;
+ DOM_SID act_sid;
+
+ SEC_ACE ace[3];
+ SEC_ACCESS mask;
+
+ SEC_ACL *psa = NULL;
+
+ sid_copy(&adm_sid, &global_sid_Builtin);
+ sid_append_rid(&adm_sid, BUILTIN_ALIAS_RID_ADMINS);
+
+ sid_copy(&act_sid, &global_sid_Builtin);
+ sid_append_rid(&act_sid, BUILTIN_ALIAS_RID_ACCOUNT_OPS);
+
+ /*basic access for every one*/
+ init_sec_access(&mask, GENERIC_RIGHTS_SAM_EXECUTE | GENERIC_RIGHTS_SAM_READ);
+ init_sec_ace(&ace[0], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0);
+
+ /*full access for builtin aliases Administrators and Account Operators*/
+ init_sec_access(&mask, GENERIC_RIGHTS_SAM_ALL_ACCESS);
+ init_sec_ace(&ace[1], &adm_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0);
+ init_sec_ace(&ace[2], &act_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0);
+
+ if ((psa = make_sec_acl(ctx, NT4_ACL_REVISION, 3, ace)) == NULL)
+ return NT_STATUS_NO_MEMORY;
+
+ if ((*psd = make_sec_desc(ctx, SEC_DESC_REVISION, SEC_DESC_SELF_RELATIVE, NULL, NULL, NULL, psa, sd_size)) == NULL)
+ return NT_STATUS_NO_MEMORY;
+
+ return NT_STATUS_OK;
+}
diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c
index 8acdab355a..b13ec1f0da 100644
--- a/source3/lib/util_str.c
+++ b/source3/lib/util_str.c
@@ -1695,6 +1695,20 @@ void str_list_free(char ***list)
}
/******************************************************************************
+ *****************************************************************************/
+
+int str_list_count( const char **list )
+{
+ int i = 0;
+
+ /* count the number of list members */
+
+ for ( i=0; *list; i++, list++ );
+
+ return i;
+}
+
+/******************************************************************************
version of standard_sub_basic() for string lists; uses alloc_sub_basic()
for the work
*****************************************************************************/
diff --git a/source3/lib/util_unistr.c b/source3/lib/util_unistr.c
index 55a21ebcbb..04985c6ab6 100644
--- a/source3/lib/util_unistr.c
+++ b/source3/lib/util_unistr.c
@@ -283,6 +283,19 @@ void unistr2_to_ascii(char *dest, const UNISTR2 *str, size_t maxlen)
}
/*******************************************************************
+ Convert a (little-endian) UNISTR3 structure to an ASCII string
+********************************************************************/
+void unistr3_to_ascii(char *dest, const UNISTR3 *str, size_t maxlen)
+{
+ if (str == NULL) {
+ *dest='\0';
+ return;
+ }
+ pull_ucs2(NULL, dest, str->str.buffer, maxlen, str->uni_str_len*2,
+ STR_NOALIGN);
+}
+
+/*******************************************************************
give a static string for displaying a UNISTR2
********************************************************************/
const char *unistr2_static(const UNISTR2 *str)
@@ -311,18 +324,6 @@ char *unistr2_tdup(TALLOC_CTX *ctx, const UNISTR2 *str)
/*******************************************************************
-Return a number stored in a buffer
-********************************************************************/
-
-uint32 buffer2_to_uint32(BUFFER2 *str)
-{
- if (str->buf_len == 4)
- return IVAL(str->buffer, 0);
- else
- return 0;
-}
-
-/*******************************************************************
Convert a wchar to upper case.
********************************************************************/