static int getfb64_main(int argc, char **argv) { if (!nvram_get_file(argv[1], argv[2], 10240)) { fprintf(stderr, "Unable to get %s or write %s\n", argv[1], argv[2]); return 1; } return 0; }
static inline int check_host_key(const char *ktype, const char *nvname, const char *hkfn) { unlink(hkfn); if (!nvram_get_file(nvname, hkfn, 2048)) { eval("dropbearkey", "-t", (char *)ktype, "-f", (char *)hkfn); if (nvram_set_file(nvname, hkfn, 2048)) { return 1; } } return 0; }
void start_nocat(void) { FILE *fp; char splashfile[255]; char logofile[255]; char iconfile[255]; char cpcmd[255]; char *p; stop_nocat(); if( !nvram_match( "NC_enable", "1" ) ) return; /* not needed .. but this is what it's testing depending on kernel.. should be modified in /nocat/src/nocat.conf #ifdef LINUX26 syslog(LOG_INFO,"Device using K2.6\n"); syslog(LOG_INFO,"tested & bypassed modprobe xt_mark\n"); syslog(LOG_INFO,"tested & bypassed modprobe xt_mac\n"); #else syslog(LOG_INFO,"Device using K2.4\n"); syslog(LOG_INFO,"Tested & bypassed modprobe ipt_mark\n"); syslog(LOG_INFO,"Tested & bypassed modprobe ipt_mac\n"); #endif */ build_nocat_conf(); if ((p = nvram_get("NC_DocumentRoot")) == NULL) p = "/tmp/splashd"; sprintf( splashfile, "%s/splash.html", p ); sprintf( logofile, "%s/tux.png", p ); sprintf( iconfile, "%s/favicon.ico", p ); if (!f_exists(splashfile)) { nvram_get_file("NC_SplashFile", splashfile, 8192); if (!f_exists(splashfile)) { sprintf(cpcmd, "cp /www/splash.html %s", splashfile); system(cpcmd); sprintf(cpcmd, "cp /www/tux.png %s", logofile); system(cpcmd); sprintf(cpcmd, "cp /www/favicon.ico %s", iconfile); system(cpcmd); } } if( !( fp = fopen( "/tmp/start_splashd.sh", "w" ) ) ) { perror( "/tmp/start_splashd.sh" ); return; } // if ( !pidof("splashd") > 0 && (fp = fopen("/tmp/var/lock/splashd.lock", "r" ) ) ) // { // unlink( "/tmp/var/lock/splashd.lock"); // } fprintf( fp, "#!/bin/sh\n" ); fprintf( fp, "LOGGER=logger\n"); fprintf( fp, "LOCK_FILE=/tmp/var/lock/splashd.lock\n"); fprintf( fp, "if [ -f $LOCK_FILE ]; then\n"); fprintf( fp, " $LOGGER \"Captive Portal halted (0), other process starting.\" \n"); fprintf( fp, " exit\n"); fprintf( fp, "fi\n"); fprintf( fp, "echo \"TOMATO_RAF\" > $LOCK_FILE\n"); fprintf( fp, "sleep 20\n" ); fprintf( fp, "$LOGGER \"splashd : Captive Portal Splash Daemon successfully started\" \n"); fprintf( fp, "echo 1 > /proc/sys/net/ipv4/tcp_tw_reuse\n"); fprintf( fp, "/usr/sbin/splashd >> /tmp/nocat.log 2>&1 &\n" ); fprintf( fp, "sleep 2\n" ); fprintf( fp, "echo 0 > /proc/sys/net/ipv4/tcp_tw_reuse\n"); fprintf( fp, "rm $LOCK_FILE\n"); fclose( fp ); chmod( "/tmp/start_splashd.sh", 0700 ); xstart( "/tmp/start_splashd.sh" ); return; }