--- projects/libstatgrab/src/saidar/saidar.c 2003/10/18 14:00:21 1.7 +++ projects/libstatgrab/src/saidar/saidar.c 2003/10/20 15:25:48 1.10 @@ -210,7 +210,9 @@ void display_data(){ char *ptr; move(0,12); - strncpy(hostname, stats.general_stats->hostname, sizeof(hostname)); + strncpy(hostname, stats.general_stats->hostname, (sizeof(hostname) - 1)); + /* strncpy does not NULL terminate.. If only strlcpy was on all platforms :) */ + hostname[14] = '\0'; ptr=strchr(hostname, '.'); /* Some hosts give back a FQDN for hostname. To avoid this, we'll * just blank out everything after the first "." @@ -333,7 +335,7 @@ void display_data(){ move(13+stats.network_entries+counter, 62); printw("%7s", size_conv(disk_stat_ptr->avail)); move(13+stats.network_entries+counter, 73); - printw("%5.2f%%", 100.00 * ((float) (disk_stat_ptr->size - disk_stat_ptr->avail) / (float) disk_stat_ptr->size)); + printw("%5.2f%%", 100.00 * ((float) disk_stat_ptr->used / (float) (disk_stat_ptr->used + disk_stat_ptr->avail))); disk_stat_ptr++; } @@ -395,7 +397,20 @@ int main(int argc, char **argv){ char ch; int delay=2; - +#ifdef ALLBSD + gid_t gid; +#endif + if(statgrab_init() != 0){ + fprintf(stderr, "statgrab_init failed. Please check the permissions\n"); + return 1; + } +#ifdef ALLBSD + if((setegid(getgid())) != 0){ + fprintf(stderr, "Failed to lose setgid'ness\n"); + return 1; + } +#endif + while ((c = getopt(argc, argv, "vhd:")) != EOF){ switch (c){ case 'd':