summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2001-02-12 16:18:02 +0000
committerJeremy Allison <jra@samba.org>2001-02-12 16:18:02 +0000
commit94fc44a93c46cece9b9fa947bff62087dbcd89fa (patch)
tree292e61a7af5427e683d483a7afd802933ced9b72 /source3/lib
parentb4b387e31b241dcf4c8359c8515db689946654d5 (diff)
downloadsamba-94fc44a93c46cece9b9fa947bff62087dbcd89fa.tar.gz
samba-94fc44a93c46cece9b9fa947bff62087dbcd89fa.tar.bz2
samba-94fc44a93c46cece9b9fa947bff62087dbcd89fa.zip
Merge of JohnR's changes to appliance-head, JF's changes to 2.2,
updated the POSIX_ACL code to be in sync. Jeremy. (This used to be commit c0517d6f4e3079feca1309fd1ea7b21e83f0de02)
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/debug.c128
-rw-r--r--source3/lib/messages.c3
-rw-r--r--source3/lib/msrpc_use.c4
3 files changed, 125 insertions, 10 deletions
diff --git a/source3/lib/debug.c b/source3/lib/debug.c
index 9d520b6c2f..e7772bbd38 100644
--- a/source3/lib/debug.c
+++ b/source3/lib/debug.c
@@ -82,7 +82,8 @@
FILE *dbf = NULL;
pstring debugf = "";
BOOL append_log = False;
-int DEBUGLEVEL = 1;
+int DEBUGLEVEL_CLASS[DBGC_LAST];
+int DEBUGLEVEL = DEBUGLEVEL_CLASS;
/* -------------------------------------------------------------------------- **
@@ -114,22 +115,137 @@ static int syslog_level = 0;
static pstring format_bufr = { '\0' };
static size_t format_pos = 0;
+/*
+* Define all the debug class selection names here. Names *MUST NOT* contain
+* white space. There must be one name for each DBGC_<class name>, and they
+* must be in the table in the order of DBGC_<class name>..
+*/
+char *classname_table[] = {
+ "all", /* DBGC_ALL; index references traditional DEBUGLEVEL */
+ "tdb", /* DBGC_TDB */
+ "printdrivers", /* DBGC_PRINTDRIVERS */
+ "lanman", /* DBGC_LANMAN */
+};
+
/* -------------------------------------------------------------------------- **
* Functions...
*/
/****************************************************************************
+utility access to debug class names's
+****************************************************************************/
+char* debug_classname_from_index(int idx)
+{
+ return classname_table[idx];
+}
+
+/****************************************************************************
+utility to translate names to debug class index's
+****************************************************************************/
+int debug_lookup_classname(char* classname)
+{
+ int i;
+
+ if (!classname) return -1;
+
+ for (i=0; i<DBGC_LAST; i++) {
+ if (strcmp(classname, classname_table[i])==0)
+ return i;
+ }
+ return -1;
+}
+
+/****************************************************************************
+parse the debug levels from smbcontrol. Example debug level parameter:
+ printdrivers:7
+****************************************************************************/
+BOOL debug_parse_params(char **params, int *debuglevel_class)
+{
+ int i, idx;
+ char *class_name;
+ char *class_level;
+
+ /* Set the new debug level array to the current DEBUGLEVEL array */
+ memcpy(debuglevel_class, DEBUGLEVEL_CLASS, sizeof(DEBUGLEVEL_CLASS));
+
+ /* Allow DBGC_ALL to be specifies w/o requiring its class name e.g."10"
+ * v.s. "all:10", this is the traditional way to set DEBUGLEVEL
+ */
+ if (isdigit(params[0][0])) {
+ debuglevel_class[DBGC_ALL] = atoi(params[0]);
+ i = 1; /* start processing at the next params */
+ }
+ else
+ i = 0; /* DBGC_ALL not specified OR calss name was included */
+
+ /* Fill in new debug class levels */
+ for (; i < DBGC_LAST && params[i]; i++) {
+ if ((class_name=strtok(params[i],":")) &&
+ (class_level=strtok(NULL, "\0")) &&
+ ((idx = debug_lookup_classname(class_name)) != -1)) {
+ debuglevel_class[idx] = atoi(class_level);
+ } else {
+ DEBUG(0,("debug_parse_params: unrecognized debug class name or format [%s]\n", params[i]));
+ return False;
+ }
+ }
+
+ return True;
+}
+
+/****************************************************************************
+parse the debug levels from smb.conf. Example debug level string:
+ 3 tdb:5 printdrivers:7
+Note: the 1st param has no "name:" preceeding it.
+****************************************************************************/
+BOOL debug_parse_levels(char *params_str)
+{
+ int i;
+ char *params[DBGC_LAST];
+ int debuglevel_class[DBGC_LAST];
+
+ ZERO_ARRAY(params);
+ ZERO_ARRAY(debuglevel_class);
+
+ if ( (params[0]=strtok(params_str," ,")) ) {
+ for (i=1; i<DBGC_LAST;i++) {
+ if ((params[i]=strtok(NULL," ,"))==NULL)
+ break;
+ }
+ }
+ else
+ return False;
+
+ if (debug_parse_params(params, debuglevel_class)) {
+ debug_message(0, getpid(), (void*)debuglevel_class, sizeof(debuglevel_class));
+ return True;
+ } else
+ return False;
+}
+
+/****************************************************************************
receive a "set debug level" message
****************************************************************************/
void debug_message(int msg_type, pid_t src, void *buf, size_t len)
{
- int level;
- memcpy(&level, buf, sizeof(int));
- DEBUGLEVEL = level;
- DEBUG(1,("INFO: Debug level set to %d from pid %d\n", level, (int)src));
+ int i;
+
+ /* Set the new DEBUGLEVEL_CLASS array from the pased array */
+ memcpy(DEBUGLEVEL_CLASS, buf, sizeof(DEBUGLEVEL_CLASS));
+
+ DEBUG(1,("INFO: Debug class %s level = %d (pid %d from pid %d)\n",
+ classname_table[DBGC_ALL],
+ DEBUGLEVEL_CLASS[DBGC_ALL], getpid(), (int)src));
+
+ for (i=1; i<DBGC_LAST; i++) {
+ if (DEBUGLEVEL_CLASS[i])
+ DEBUGADD(1,("INFO: Debug class %s level = %d\n",
+ classname_table[i], DEBUGLEVEL_CLASS[i]));
+ }
}
+
/****************************************************************************
send a "set debug level" message
****************************************************************************/
@@ -175,7 +291,7 @@ void reopen_logs( void )
pstring fname;
mode_t oldumask;
- if (DEBUGLEVEL <= 0) {
+ if (DEBUGLEVEL_CLASS[ DBGC_ALL ] <= 0) {
if (dbf) {
(void)fclose(dbf);
dbf = NULL;
diff --git a/source3/lib/messages.c b/source3/lib/messages.c
index 6f6d99c8ec..19496bd426 100644
--- a/source3/lib/messages.c
+++ b/source3/lib/messages.c
@@ -73,7 +73,6 @@ void ping_message(int msg_type, pid_t src, void *buf, size_t len)
DEBUG(1,("INFO: Received PING message from PID %d\n",src));
message_send_pid(src, MSG_PONG, buf, len, True);
}
-
/****************************************************************************
return current debug level
****************************************************************************/
@@ -83,7 +82,7 @@ void debuglevel_message(int msg_type, pid_t src, void *buf, size_t len)
DEBUG(1,("INFO: Received REQ_DEBUGLEVEL message from PID %d\n",src));
level = DEBUGLEVEL;
- message_send_pid(src, MSG_DEBUGLEVEL, &level, sizeof(int), True);
+ message_send_pid(src, MSG_DEBUGLEVEL, DEBUGLEVEL_CLASS, sizeof(DEBUGLEVEL_CLASS), True);
}
/****************************************************************************
diff --git a/source3/lib/msrpc_use.c b/source3/lib/msrpc_use.c
index 7558a266b3..90fac637b3 100644
--- a/source3/lib/msrpc_use.c
+++ b/source3/lib/msrpc_use.c
@@ -109,7 +109,7 @@ find client state. server name, user name, domain name and password must all
match.
****************************************************************************/
static struct msrpc_use *msrpc_find(const char* pipe_name,
- const struct user_creds *usr_creds)
+ struct user_creds *usr_creds)
{
int i;
struct user_creds null_usr;
@@ -199,7 +199,7 @@ init client state
****************************************************************************/
struct msrpc_state *msrpc_use_add(const char* pipe_name,
uint32 pid,
- const struct user_creds *usr_creds,
+ struct user_creds *usr_creds,
BOOL redir)
{
struct msrpc_use *cli;