network_service.cpp: acitve menu only if binary available (tiny fix)

Origin commit data
------------------
Commit: 40941dd949
Author: Jacek Jendrzej <overx300@gmail.com>
Date: 2012-07-13 (Fri, 13 Jul 2012)
This commit is contained in:
Jacek Jendrzej
2012-07-13 16:20:56 +02:00
parent 189612d698
commit 3b1ab03ebb

View File

@@ -51,8 +51,8 @@ struct network_service
#define SERVICE_COUNT 4 #define SERVICE_COUNT 4
static struct network_service services[SERVICE_COUNT] = static struct network_service services[SERVICE_COUNT] =
{ {
{ "FTP", "vsftpd", "", LOCALE_MENU_HINT_NET_TELNET, "", 0 }, { "FTP", "vsftpd", "", LOCALE_MENU_HINT_NET_FTPD, "", 0 },
{ "Telnet", "telnetd", "-l/bin/login", LOCALE_MENU_HINT_NET_FTPD, "", 0 }, { "Telnet", "telnetd", "-l/bin/login", LOCALE_MENU_HINT_NET_TELNET, "", 0 },
{ "DjMount", "djmount", "-o iocharset=utf8 /media/00upnp/", LOCALE_MENU_HINT_NET_DJMOUNT, "", 0 }, { "DjMount", "djmount", "-o iocharset=utf8 /media/00upnp/", LOCALE_MENU_HINT_NET_DJMOUNT, "", 0 },
{ "uShare", "ushare", "-D", LOCALE_MENU_HINT_NET_USHARE, "", 0 } { "uShare", "ushare", "-D", LOCALE_MENU_HINT_NET_USHARE, "", 0 }
}; };
@@ -144,16 +144,17 @@ int CNetworkServiceSetup::showNetworkServiceSetup()
//telnetd used inetd //telnetd used inetd
bool useinetd = false; bool useinetd = false;
char line[256]; char *buf=NULL;
size_t len = 0;
FILE* fd = fopen("/etc/inetd.conf", "r"); FILE* fd = fopen("/etc/inetd.conf", "r");
if(fd) if(fd)
{ {
while(!feof(fd)) while(!feof(fd))
{ {
fgets(line, 255, fd); if(getline(&buf, &len, fd)!=-1)
{ {
if (strstr(line, "telnetd") != NULL) if (strstr(buf, "telnetd") != NULL)
{ {
useinetd = true; useinetd = true;
break; break;
@@ -161,10 +162,12 @@ int CNetworkServiceSetup::showNetworkServiceSetup()
} }
} }
fclose(fd); fclose(fd);
if(buf)
free(buf);
} }
//set active when found //set active when found
int active; bool active;
for(unsigned i = 0; i < SERVICE_COUNT; i++) { for(unsigned i = 0; i < SERVICE_COUNT; i++) {
items[i] = new CNetworkService(services[i].cmd, services[i].options); items[i] = new CNetworkService(services[i].cmd, services[i].options);