Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 20 Aug 2007 13:38:47 GMT
From:      Alexey Mikhailov <karma@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 125407 for review
Message-ID:  <200708201338.l7KDclxw082768@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=125407

Change 125407 by karma@karma_ez on 2007/08/20 13:38:46

	- Add missing routines for configuration parsing
	- Fix last commit

Affected files ...

.. //depot/projects/soc2007/karma_audit/dlog/daemon/client.c#7 edit
.. //depot/projects/soc2007/karma_audit/dlog/daemon/config.c#7 edit
.. //depot/projects/soc2007/karma_audit/dlog/daemon/config.h#7 edit
.. //depot/projects/soc2007/karma_audit/dlog/lib/libdlogd.c#5 edit
.. //depot/projects/soc2007/karma_audit/dlog/lib/libdlogd.h#4 edit

Differences ...

==== //depot/projects/soc2007/karma_audit/dlog/daemon/client.c#7 (text+ko) ====

@@ -103,11 +103,12 @@
                                 snprintf(jobbuf, PATH_MAX, "%s/.%ld.%s.hds", pathbuf,ts,basename(pathname));
                                 fd = open(jobbuf, O_CREAT | O_TRUNC, S_IRUSR | S_IRGRP);
                                 hl = client_get_hosts(keyword);
-                                while (hl == NULL) {
+                                while (hl != NULL) {
                                         bzero(&j, sizeof(j));
                                         memcpy(&(j.sa), &(hl->hs->s), sizeof(struct sockaddr));
                                         j.done = 0;
                                         write(fd, &j, sizeof(j));
+                                        hl = hl -> next;
                                 }
                                 close(fd);
                                 /* we re done */
@@ -123,8 +124,10 @@
                         return ;
                 }
         } else {
-                /* TODO: can't check permissions. wrong query */
-                fprintf(stderr,"client: can't check permissions");
+                /* Can't check permission */
+                ans = 1;
+                write(cs, &ans, sizeof(ans));
+                return ;
         }
 }
 

==== //depot/projects/soc2007/karma_audit/dlog/daemon/config.c#7 (text+ko) ====

@@ -402,5 +402,40 @@
 char *
 verify_server_access (struct sockaddr * sa, const char * keyword)
 {
-        return 0;
+        sv_kw_data * sk;
+        sv_kw_hostdir * hs;
+        host_ll * h;
+
+        sk = (sv_kw_data *) search_tree (server_kw_tree, keyword);
+
+        if (sk == NULL) {
+                return NULL; /* bad keyword */
+        }
+        
+        hs = sk -> hds;
+
+        while (hs != NULL) {
+                h = hs -> hs;
+                while (h != NULL) {
+                        if (strcmp(h -> s.sa_data, sa -> sa_data) == 0) {
+                                return (hs -> dir);
+                        }
+                }
+        }
+
+        return NULL;
+}
+
+cl_kw_hosts *
+client_get_hosts (const char * keyword)
+{
+        cl_kw_data * ck;
+
+        ck = (cl_kw_data *) search_tree(client_kw_tree, keyword);
+
+        if (ck == NULL) {
+                return NULL; /* bad keyword */
+        }
+
+        return ck -> hosts;
 }

==== //depot/projects/soc2007/karma_audit/dlog/daemon/config.h#7 (text+ko) ====


==== //depot/projects/soc2007/karma_audit/dlog/lib/libdlogd.c#5 (text+ko) ====

@@ -14,8 +14,29 @@
 #include <sys/un.h>
 #include <sys/ucred.h>
 
+static const char *dlog_errlist[] = {
+        "Success",                          
+        "Can't create socket", 
+        "Can't bind() on socket",
+        "Can't chmod() on socket",
+        "Can't connect() on socket",
+        "Can't sendmsg() on socket",
+        "Can't read() from socket",
+        "Bad response from server"
+};
+
+
 static int dlogd_connect ();
 
+const char *
+dlog_strerror (int code)
+{
+        if (code >= 0 && code <= 7) {
+                return dlog_errlist[-code];
+        }
+        return "Unknown error";
+}
+
 /* Submit log file 
 
    On success: 0 returned

==== //depot/projects/soc2007/karma_audit/dlog/lib/libdlogd.h#4 (text+ko) ====

@@ -2,5 +2,6 @@
 #define DLOG_LIB_H
 
 int dlogd_submit(const char * pathname, const char * keyword);
+const char * dlog_strerror(int code);
 
 #endif



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200708201338.l7KDclxw082768>