levellist_t levellist;
char number[NUM_STR_SIZE];
for (levellist=dle->levellist; levellist; levellist=levellist->next) {
- level_t *alevel = (level_t *)levellist->data;
+ am_level_t *alevel = (am_level_t *)levellist->data;
g_ptr_array_add(argv_ptr, stralloc("--level"));
g_snprintf(number, SIZEOF(number), "%d", alevel->level);
g_ptr_array_add(argv_ptr, stralloc(number));
FILE *dumpout = NULL;
int dumpsince;
char *errmsg = NULL;
- off_t size = (off_t)1;
char *line = NULL;
amwait_t wait_status;
int len;
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;
dbprintf(_("estimate size for %s level %d: %lld KB\n"),
qdisk, level, size_);
}
- size = (off_t)size_;
}
amfree(match_expr);
amfree(errmsg);
g_ptr_array_free_full(argv_ptr);
amfree(cmd);
-
}
-void
+gboolean
check_access(
char * filename,
int mode)
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)
quoted = quote_string(filename);
g_printf(_("ERROR [%s is not a file]\n"), quoted);
amfree(quoted);
+ return FALSE;
}
} else {
int save_errno = errno;
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)
quoted = quote_string(dirname);
g_printf(_("ERROR [%s is not a directory]\n"), quoted);
amfree(quoted);
+ return FALSE;
}
} else {
int save_errno = errno;
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)
{
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;
}
/*