From owner-p4-projects@FreeBSD.ORG Mon Aug 20 13:38:48 2007 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 2110216A41B; Mon, 20 Aug 2007 13:38:48 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BD2C516A419 for ; Mon, 20 Aug 2007 13:38:47 +0000 (UTC) (envelope-from karma@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id AC5BA13C442 for ; Mon, 20 Aug 2007 13:38:47 +0000 (UTC) (envelope-from karma@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id l7KDcl5m082773 for ; Mon, 20 Aug 2007 13:38:47 GMT (envelope-from karma@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id l7KDclxw082768 for perforce@freebsd.org; Mon, 20 Aug 2007 13:38:47 GMT (envelope-from karma@FreeBSD.org) Date: Mon, 20 Aug 2007 13:38:47 GMT Message-Id: <200708201338.l7KDclxw082768@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to karma@FreeBSD.org using -f From: Alexey Mikhailov To: Perforce Change Reviews Cc: Subject: PERFORCE change 125407 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Aug 2007 13:38:48 -0000 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 #include +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