{
char **myargv;
char aLine[MAX_LENGTH];
+#ifdef HAVE_CHROOT
char *firstdir="";
+#endif
#ifdef MUST_DISABLE_SIGFPE
signal(SIGFPE,SIG_IGN);
#endif
gettimeofday(&starttime,&tz);
#endif
RemoteMode=1;
-#ifndef WIN32
+#ifdef HAVE_CHROOT
if ((argc == 3) && strcmp("",argv[2])){
if (getuid()==0){
chroot(argv[2]);
}
}
#else
- fprintf(stderr,"ERROR: change root only in unix "
- "enviroment posible\n");
+ fprintf(stderr,"ERROR: change root is not supported by your OS "
+ "or at least by this copy of rrdtool\n");
exit(1);
#endif
return 0;
}
+/* HandleInputLine is NOT thread safe - due to readdir issues,
+ resolving them portably is not really simple. */
int HandleInputLine(int argc, char **argv, FILE* out)
{
+#if defined(HAVE_OPENDIR) && defined (HAVE_READDIR)
DIR *curdir; /* to read current dir with ls */
struct dirent *dent;
+#endif
+#if defined(HAVE_SYS_STAT_H)
struct stat st;
+#endif
optind=0; /* reset gnu getopt */
opterr=0; /* no error messages */
}
exit(0);
}
+#if defined(HAVE_OPENDIR) && defined(HAVE_READDIR) && defined(HAVE_CHDIR)
if (argc>1 && strcmp("cd", argv[1]) == 0){
if (argc>3){
printf("ERROR: invalid parameter count for cd\n");
return(0);
}
-#ifndef WIN32
+#if ! defined(HAVE_CHROOT) || ! defined(HAVE_GETUID)
if (getuid()==0 && ! ChangeRoot){
printf("ERROR: chdir security problem - rrdtool is runnig as "
"root an no chroot!\n");
printf("ERROR: invalid parameter count for mkdir\n");
return(0);
}
-#ifndef WIN32
+#if ! defined(HAVE_CHROOT) || ! defined(HAVE_GETUID)
if (getuid()==0 && ! ChangeRoot){
printf("ERROR: mkdir security problem - rrdtool is runnig as "
"root an no chroot!\n");
}
return(0);
}
+#endif /* opendir and readdir */
+
}
if (argc < 3
|| strcmp("help", argv[1]) == 0
else if (strcmp("update", argv[1]) == 0)
rrd_update(argc-1, &argv[1]);
else if (strcmp("fetch", argv[1]) == 0) {
- time_t start,end;
+ time_t start,end, ti;
unsigned long step, ds_cnt,i,ii;
rrd_value_t *data,*datai;
char **ds_namv;
for (i = 0; i<ds_cnt;i++)
printf("%14s",ds_namv[i]);
printf ("\n\n");
- for (i = start+step; i <= end; i += step){
- printf("%10lu:", i);
+ for (ti = start+step; ti <= end; ti += step){
+ printf("%10lu:", ti);
for (ii = 0; ii < ds_cnt; ii++)
printf(" %0.10e", *(datai++));
printf("\n");
}
} else if (strcmp("xport", argv[1]) == 0) {
int xxsize;
- int i = 0, j = 0;
- time_t start,end;
+ unsigned long int j = 0;
+ time_t start,end, ti;
unsigned long step, col_cnt,row_cnt;
rrd_value_t *data,*ptr;
char **legend_v;
printf(" </%s>\n", LEGEND_TAG);
printf(" </%s>\n", META_TAG);
printf(" <%s>\n", DATA_TAG);
- for (i = start+step; i <= end; i += step) {
+ for (ti = start+step; ti <= end; ti += step) {
printf (" <%s>", DATA_ROW_TAG);
- printf ("<%s>%lu</%s>", COL_TIME_TAG, i, COL_TIME_TAG);
+ printf ("<%s>%lu</%s>", COL_TIME_TAG, ti, COL_TIME_TAG);
for (j = 0; j < col_cnt; j++) {
rrd_value_t newval = DNAN;
newval = *ptr;