From 81ca577fb811a476a2d28e88404f6cdcb2b15569 Mon Sep 17 00:00:00 2001 From: martii Date: Sun, 30 Jun 2013 17:00:34 +0200 Subject: [PATCH] overload access(2) Conflicts: src/driver/pictureviewer/pictureviewer.cpp src/gui/components/cc_item_picture.cpp src/gui/movieplayer.cpp src/gui/osdlang_setup.cpp src/neutrino.cpp src/nhttpd/tuxboxapi/coolstream/neutrinoapi.cpp src/nhttpd/yhttpd.cpp src/system/helpers.h src/system/setting_helpers.cpp --- src/gui/filebrowser.cpp | 2 +- src/gui/moviebrowser.cpp | 2 +- src/gui/network_service.cpp | 4 ++-- src/gui/osdlang_setup.cpp | 12 +++++++++--- src/nhttpd/tuxboxapi/dbox/neutrinoyparser.cpp | 2 +- src/nhttpd/yhttpd.cpp | 7 ++++--- src/nhttpd/yhttpd_core/ylanguage.cpp | 6 ++++-- src/nhttpd/yhttpd_mods/mod_sendfile.cpp | 11 ++++++----- src/nhttpd/yhttpd_mods/mod_weblog.cpp | 3 ++- src/nhttpd/yhttpd_mods/mod_yparser.cpp | 5 +++-- src/system/configure_network.cpp | 2 +- src/system/setting_helpers.cpp | 3 ++- src/system/ytcache.cpp | 8 ++++---- src/system/ytparser.cpp | 3 ++- 14 files changed, 42 insertions(+), 28 deletions(-) diff --git a/src/gui/filebrowser.cpp b/src/gui/filebrowser.cpp index 6a47c0da9..e3a4d02dc 100644 --- a/src/gui/filebrowser.cpp +++ b/src/gui/filebrowser.cpp @@ -392,7 +392,7 @@ void CFileBrowser::ChangeDir(const std::string & filename, int selection) std::string extension = file->Name.substr(ext_pos + 1, name.length() - ext_pos); if(strcasecmp(extension.c_str(), "ts") == 0) { std::string fname = file->Name.substr(0, ext_pos) + ".xml"; - if(access(fname.c_str(), F_OK) == 0) + if(access(fname, F_OK) == 0) continue; } } diff --git a/src/gui/moviebrowser.cpp b/src/gui/moviebrowser.cpp index 34904ed51..66395b79b 100644 --- a/src/gui/moviebrowser.cpp +++ b/src/gui/moviebrowser.cpp @@ -1307,7 +1307,7 @@ std::string CMovieBrowser::getScreenshotName(std::string movie) ext = *it; ret.replace(found, ext.length(), ext); ++it; - if (!access(ret.c_str(), F_OK)) + if (!access(ret, F_OK)) return ret; } return ""; diff --git a/src/gui/network_service.cpp b/src/gui/network_service.cpp index 7decd099f..70302c30f 100644 --- a/src/gui/network_service.cpp +++ b/src/gui/network_service.cpp @@ -68,7 +68,7 @@ CNetworkService::CNetworkService(std::string cmd, std::string opts) enabled = false; std::string file = TOUCH_BASE + cmd; - if (!access(file.c_str(), F_OK)) + if (!access(file, F_OK)) enabled = true; } @@ -181,7 +181,7 @@ int CNetworkServiceSetup::showNetworkServiceSetup() std::string execute2 = "/sbin/" + services[i].cmd; active = false; - if ( !(access(execute1.c_str(), F_OK)) || !(access(execute2.c_str(), F_OK)) ) + if ( !(access(execute1, F_OK)) || !(access(execute2, F_OK)) ) active = true; if ( (services[i].name == "Telnet") && useinetd) diff --git a/src/gui/osdlang_setup.cpp b/src/gui/osdlang_setup.cpp index 79b1b8c23..4f72dbdac 100644 --- a/src/gui/osdlang_setup.cpp +++ b/src/gui/osdlang_setup.cpp @@ -46,6 +46,7 @@ #include #include +#include #include #include @@ -145,10 +146,15 @@ CMenuOptionStringChooser* COsdLangSetup::getTzItems() if (!strcmp(xmlGetName(search), "zone")) { std::string name = xmlGetAttribute(search, "name"); -// std::string zone = xmlGetAttribute(search, "zone"); + std::string zone = xmlGetAttribute(search, "zone"); //printf("Timezone: %s -> %s\n", name.c_str(), zone.c_str()); - tzSelect->addOption(name.c_str()); - found = true; + if (access("/usr/share/zoneinfo/" + zone, R_OK)) + printf("[neutrino] timezone file '%s' not installed\n", zone.c_str()); + else + { + tzSelect->addOption(name); + found = true; + } } search = search->xmlNextNode; } diff --git a/src/nhttpd/tuxboxapi/dbox/neutrinoyparser.cpp b/src/nhttpd/tuxboxapi/dbox/neutrinoyparser.cpp index 5d510215b..844d31c0e 100644 --- a/src/nhttpd/tuxboxapi/dbox/neutrinoyparser.cpp +++ b/src/nhttpd/tuxboxapi/dbox/neutrinoyparser.cpp @@ -316,7 +316,7 @@ std::string CNeutrinoYParser::func_get_bouquets_with_epg(CyhookHandler *hh, std: std::string timestr; bool have_logos = false; - if(hh->WebserverConfigList["TUXBOX_LOGOS_URL"] != "" ||hh->WebserverConfigList["ExtrasDocumentRoot"] == "web" || (access((hh->WebserverConfigList["ExtrasDocumentRoot"]+"/logos").c_str(),4)==0) ) + if(hh->WebserverConfigList["TUXBOX_LOGOS_URL"] != "" ||hh->WebserverConfigList["ExtrasDocumentRoot"] == "web" || (access(hh->WebserverConfigList["ExtrasDocumentRoot"]+"/logos",R_OK)==0) ) have_logos = true; CZapitClient::BouquetChannelList::iterator channel = channellist->begin(); for (; channel != channellist->end();channel++) diff --git a/src/nhttpd/yhttpd.cpp b/src/nhttpd/yhttpd.cpp index d0ceba730..2f37c1ce9 100644 --- a/src/nhttpd/yhttpd.cpp +++ b/src/nhttpd/yhttpd.cpp @@ -13,6 +13,7 @@ #include #include +#include // yhttpd #include "yconfig.h" #include @@ -549,16 +550,16 @@ void Cyhttpd::ReadConfig(void) { // Check location of logos if (Config->getString("Tuxbox.LogosURL", "") == "") { - if (access(std::string(ConfigList["WebsiteMain.override_directory"] + "/logos").c_str(), R_OK) == 0) { + if (access(ConfigList["WebsiteMain.override_directory"] + "/logos", R_OK) == 0) { Config->setString("Tuxbox.LogosURL", ConfigList["WebsiteMain.override_directory"] + "/logos"); have_config = false; //save config } - else if (access(std::string(ConfigList["WebsiteMain.directory"] + "/logos").c_str(), R_OK) == 0) { + else if (access(ConfigList["WebsiteMain.directory"] + "/logos", R_OK) == 0){ Config->setString("Tuxbox.LogosURL", ConfigList["WebsiteMain.directory"] + "/logos"); have_config = false; //save config } #ifdef Y_CONFIG_USE_HOSTEDWEB - else if (access(std::string(ConfigList["WebsiteMain.hosted_directory"] + "/logos").c_str(), R_OK) == 0) { + else if (access(ConfigList["WebsiteMain.hosted_directory"] + "/logos", R_OK) == 0){ Config->setString("Tuxbox.LogosURL", ConfigList["WebsiteMain.hosted_directory"] + "/logos"); have_config = false; //save config } diff --git a/src/nhttpd/yhttpd_core/ylanguage.cpp b/src/nhttpd/yhttpd_core/ylanguage.cpp index 9003a536a..f417afbef 100644 --- a/src/nhttpd/yhttpd_core/ylanguage.cpp +++ b/src/nhttpd/yhttpd_core/ylanguage.cpp @@ -9,6 +9,8 @@ #include #include +#include + // yhttpd #include #include @@ -109,9 +111,9 @@ std::string CLanguage::getTranslation(std::string id){ std::string CLanguage::getLanguageDir(void){ std::string tmpfilename = "/"+Cyhttpd::ConfigList["Language.directory"],dir=""; - if( access(std::string(Cyhttpd::ConfigList["WebsiteMain.override_directory"] + tmpfilename).c_str(),4) == 0) + if( access(Cyhttpd::ConfigList["WebsiteMain.override_directory"] + tmpfilename,R_OK) == 0) dir = Cyhttpd::ConfigList["WebsiteMain.override_directory"] + tmpfilename; - else if(access(std::string(Cyhttpd::ConfigList["WebsiteMain.directory"] + tmpfilename).c_str(),4) == 0) + else if(access(Cyhttpd::ConfigList["WebsiteMain.directory"] + tmpfilename,R_OK) == 0) dir = Cyhttpd::ConfigList["WebsiteMain.directory"] + tmpfilename; return dir; } diff --git a/src/nhttpd/yhttpd_mods/mod_sendfile.cpp b/src/nhttpd/yhttpd_mods/mod_sendfile.cpp index 1442ad660..4807370b0 100644 --- a/src/nhttpd/yhttpd_mods/mod_sendfile.cpp +++ b/src/nhttpd/yhttpd_mods/mod_sendfile.cpp @@ -46,6 +46,7 @@ #include #include #include +#include // yhttpd #include #include @@ -179,16 +180,16 @@ std::string CmodSendfile::GetFileName(CyhookHandler *hh, std::string path, std:: tmpfilename = path + "/" + filename; else tmpfilename = path + filename; - if (access(std::string(hh->WebserverConfigList["WebsiteMain.override_directory"] + tmpfilename).c_str(), 4) == 0) + if (access(hh->WebserverConfigList["WebsiteMain.override_directory"] + tmpfilename, R_OK) == 0) tmpfilename = hh->WebserverConfigList["WebsiteMain.override_directory"] + tmpfilename; - else if (access(std::string(hh->WebserverConfigList["WebsiteMain.override_directory"] + tmpfilename + ".gz").c_str(), 4) == 0) + else if (access(hh->WebserverConfigList["WebsiteMain.override_directory"] + tmpfilename + ".gz", R_OK) == 0) tmpfilename = hh->WebserverConfigList["WebsiteMain.override_directory"] + tmpfilename + ".gz"; - else if (access(std::string(hh->WebserverConfigList["WebsiteMain.directory"] + tmpfilename).c_str(), 4) == 0) + else if (access(hh->WebserverConfigList["WebsiteMain.directory"] + tmpfilename, R_OK) == 0) tmpfilename = hh->WebserverConfigList["WebsiteMain.directory"] + tmpfilename; - else if (access(std::string(hh->WebserverConfigList["WebsiteMain.directory"] + tmpfilename + ".gz").c_str(), 4) == 0) + else if (access(hh->WebserverConfigList["WebsiteMain.directory"] + tmpfilename + ".gz", R_OK) == 0) tmpfilename = hh->WebserverConfigList["WebsiteMain.directory"] + tmpfilename + ".gz"; #ifdef Y_CONFIG_FEATUE_SENDFILE_CAN_ACCESS_ALL - else if(access(tmpfilename.c_str(),4) == 0) + else if(access(tmpfilename,R_OK) == 0) ; #endif else { diff --git a/src/nhttpd/yhttpd_mods/mod_weblog.cpp b/src/nhttpd/yhttpd_mods/mod_weblog.cpp index 4810daa07..dff16a901 100644 --- a/src/nhttpd/yhttpd_mods/mod_weblog.cpp +++ b/src/nhttpd/yhttpd_mods/mod_weblog.cpp @@ -12,6 +12,7 @@ #include "mod_weblog.h" #include +#include //============================================================================= // Initialization of static variables @@ -67,7 +68,7 @@ bool CmWebLog::OpenLogFile() { if (WebLogFile == NULL) { bool isNew = false; pthread_mutex_lock(&WebLog_mutex); // yeah, its mine - if (access(WebLogFilename.c_str(), 4) != 0) + if (access(WebLogFilename, R_OK) != 0) isNew = true; WebLogFile = fopen(WebLogFilename.c_str(), "a"); if (isNew) { diff --git a/src/nhttpd/yhttpd_mods/mod_yparser.cpp b/src/nhttpd/yhttpd_mods/mod_yparser.cpp index e6859fb25..95c68297b 100644 --- a/src/nhttpd/yhttpd_mods/mod_yparser.cpp +++ b/src/nhttpd/yhttpd_mods/mod_yparser.cpp @@ -19,6 +19,7 @@ #include // tuxbox #include +#include // yhttpd #include #include @@ -423,7 +424,7 @@ std::string CyParser::YWeb_cgi_cmd(CyhookHandler *hh, std::string ycmd) { std::string if_value, if_then, if_else; if (ySplitString(ycmd_name, "~", if_value, if_then)) { ySplitString(if_then, "~", if_then, if_else); - yresult = (access(if_value.c_str(), 4) == 0) ? if_then + yresult = (access(if_value, R_OK) == 0) ? if_then : if_else; } } else if (ycmd_type == "include") { @@ -731,7 +732,7 @@ std::string CyParser::func_do_reload_httpd_config(CyhookHandler *, std::string) // y-func : Change httpd (process image) on the fly //------------------------------------------------------------------------- std::string CyParser::func_change_httpd(CyhookHandler *hh, std::string para) { - if (para != "" && access(para.c_str(), 4) == 0) { + if (para != "" && access(para, R_OK) == 0) { hh->status = HANDLED_ABORT; char * argv[2] = { (char *)para.c_str(), NULL }; int err = execvp(argv[0], argv); // no return if successful diff --git a/src/system/configure_network.cpp b/src/system/configure_network.cpp index c439adade..ee8815d03 100644 --- a/src/system/configure_network.cpp +++ b/src/system/configure_network.cpp @@ -104,7 +104,7 @@ void CNetworkConfig::init_vars(void) wireless = 0; std::string tmp = "/sys/class/net/" + ifname + "/wireless"; - if(access(tmp.c_str(), R_OK) == 0) + if(access(tmp, R_OK) == 0) wireless = 1; if(wireless) readWpaConfig(); diff --git a/src/system/setting_helpers.cpp b/src/system/setting_helpers.cpp index 9c8a3a0e2..0bd6aecc4 100644 --- a/src/system/setting_helpers.cpp +++ b/src/system/setting_helpers.cpp @@ -466,7 +466,8 @@ bool CTZChangeNotifier::changeNotify(const neutrino_locale_t, void * Data) name = xmlGetAttribute(search, "name"); if(g_settings.timezone == name) { zone = xmlGetAttribute(search, "zone"); - found = true; + if (!access("/usr/share/zoneinfo/" + zone, R_OK)) + found = true; break; } } diff --git a/src/system/ytcache.cpp b/src/system/ytcache.cpp index a404bbf03..2e1affdc1 100644 --- a/src/system/ytcache.cpp +++ b/src/system/ytcache.cpp @@ -69,7 +69,7 @@ bool cYTCache::getNameIfExists(std::string &fname, const std::string &id, int it char ytitag[10]; snprintf(ytitag, sizeof(ytitag), "%d", itag); std::string f = g_settings.downloadcache_dir + "/" + id + "-" + std::string(ytitag) + "." + ext; - if (access(f.c_str(), R_OK)) + if (access(f, R_OK)) return false; fname = f; return true; @@ -78,10 +78,10 @@ bool cYTCache::getNameIfExists(std::string &fname, const std::string &id, int it bool cYTCache::useCachedCopy(MI_MOVIE_INFO *mi) { std::string file = getName(mi); - if (access(file.c_str(), R_OK)) + if (access(file, R_OK)) return false; std::string xml = getName(mi, "xml"); - if (!access(xml.c_str(), R_OK)) { + if (!access(xml, R_OK)) { mi->file.Url = file; return true; } @@ -111,7 +111,7 @@ bool cYTCache::download(MI_MOVIE_INFO *mi) { std::string file = getName(mi); std::string xml = getName(mi, "xml"); - if (!access(file.c_str(), R_OK) && !access(xml.c_str(), R_OK)) { + if (!access(file, R_OK) && !access(xml, R_OK)) { fprintf(stderr, "%s: %s already present and valid\n", __func__, file.c_str()); return true; } diff --git a/src/system/ytparser.cpp b/src/system/ytparser.cpp index 974062984..ccb2146b1 100644 --- a/src/system/ytparser.cpp +++ b/src/system/ytparser.cpp @@ -32,6 +32,7 @@ #include #include "settings.h" +#include "helpers.h" #include "set_threadname.h" #include @@ -615,7 +616,7 @@ bool cYTFeedParser::DownloadThumbnail(cYTVideoInfo &vinfo, CURL *_curl_handle) bool found = false; if (!vinfo.thumbnail.empty()) { std::string fname = thumbnail_dir + "/" + vinfo.id + ".jpg"; - found = !access(fname.c_str(), F_OK); + found = !access(fname, F_OK); if (!found) { for (int *fmtp = itags; *fmtp && !found; fmtp++) found = cYTCache::getInstance()->getNameIfExists(fname, vinfo.id, *fmtp);