X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=client-src%2Fclient_util.c;h=513d9ba7402fcd180fd71d30ad5cc31b6906479b;hb=refs%2Ftags%2Fupstream%2F3.3.1;hp=89365ce44aab90e3a69c312f5615f227885396cb;hpb=cd0b924f27312d57bd42f6c4fae2b795139e2d0b;p=debian%2Famanda diff --git a/client-src/client_util.c b/client-src/client_util.c index 89365ce..513d9ba 100644 --- a/client-src/client_util.c +++ b/client-src/client_util.c @@ -1425,7 +1425,6 @@ run_calcsize( FILE *dumpout = NULL; int dumpsince; char *errmsg = NULL; - off_t size = (off_t)1; char *line = NULL; amwait_t wait_status; int len; @@ -1521,7 +1520,7 @@ run_calcsize( match_expr = vstralloc(" %d SIZE %lld", NULL); len = strlen(qdisk); - for(size = (off_t)-1; (line = agets(dumpout)) != NULL; free(line)) { + for(; (line = agets(dumpout)) != NULL; free(line)) { long long size_ = (long long)0; if (line[0] == '\0' || (int)strlen(line) <= len) continue; @@ -1532,7 +1531,6 @@ run_calcsize( dbprintf(_("estimate size for %s level %d: %lld KB\n"), qdisk, level, size_); } - size = (off_t)size_; } amfree(match_expr); @@ -1576,11 +1574,10 @@ common_exit: amfree(errmsg); g_ptr_array_free_full(argv_ptr); amfree(cmd); - } -void +gboolean check_access( char * filename, int mode) @@ -1597,14 +1594,18 @@ check_access( else noun = "access", adjective = "accessible"; - if(access(filename, mode) == -1) + if(access(filename, mode) == -1) { g_printf(_("ERROR [can not %s %s: %s]\n"), noun, quoted, strerror(errno)); - else + amfree(quoted); + return FALSE; + } else { g_printf(_("OK %s %s\n"), quoted, adjective); + } amfree(quoted); + return TRUE; } -void +gboolean check_file( char * filename, int mode) @@ -1617,6 +1618,7 @@ check_file( quoted = quote_string(filename); g_printf(_("ERROR [%s is not a file]\n"), quoted); amfree(quoted); + return FALSE; } } else { int save_errno = errno; @@ -1624,13 +1626,19 @@ check_file( g_printf(_("ERROR [can not stat %s: %s]\n"), quoted, strerror(save_errno)); amfree(quoted); + return FALSE; } if (getuid() == geteuid()) { - check_access(filename, mode); + return check_access(filename, mode); + } else { + quoted = quote_string(filename); + g_printf("OK %s\n", quoted); + amfree(quoted); } + return TRUE; } -void +gboolean check_dir( char * dirname, int mode) @@ -1644,6 +1652,7 @@ check_dir( quoted = quote_string(dirname); g_printf(_("ERROR [%s is not a directory]\n"), quoted); amfree(quoted); + return FALSE; } } else { int save_errno = errno; @@ -1651,15 +1660,23 @@ check_dir( g_printf(_("ERROR [can not stat %s: %s]\n"), quoted, strerror(save_errno)); amfree(quoted); + return FALSE; } if (getuid() == geteuid()) { + gboolean result; dir = stralloc2(dirname, "/."); - check_access(dir, mode); + result = check_access(dir, mode); amfree(dir); + return result; + } else { + quoted = quote_string(dirname); + g_printf("OK %s\n", quoted); + amfree(quoted); } + return TRUE; } -void +gboolean check_suid( char * filename) { @@ -1670,18 +1687,25 @@ check_suid( if(!stat(filename, &stat_buf)) { if(stat_buf.st_uid != 0 ) { g_printf(_("ERROR [%s is not owned by root]\n"), quoted); + amfree(quoted); + return FALSE; } if((stat_buf.st_mode & S_ISUID) != S_ISUID) { g_printf(_("ERROR [%s is not SUID root]\n"), quoted); + amfree(quoted); + return FALSE; } } else { g_printf(_("ERROR [can not stat %s: %s]\n"), quoted, strerror(errno)); + amfree(quoted); + return FALSE; } amfree(quoted); #else (void)filename; /* Quiet unused parameter warning */ #endif + return TRUE; } /*