From 25613a61f6f3b9e54d5229af7e2278d0fa54bdd9 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 26 Sep 2014 22:16:26 +0200 Subject: fix: Member variable 'X' is not initialized in the constructor. Reported-By: cppcheck Git-Dch: Ignore --- apt-pkg/cdrom.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'apt-pkg/cdrom.cc') diff --git a/apt-pkg/cdrom.cc b/apt-pkg/cdrom.cc index a5ad6a9ff..b97f7b036 100644 --- a/apt-pkg/cdrom.cc +++ b/apt-pkg/cdrom.cc @@ -913,10 +913,14 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/ return true; } /*}}}*/ -pkgUdevCdromDevices::pkgUdevCdromDevices() /*{{{*/ - : libudev_handle(NULL) +pkgUdevCdromDevices::pkgUdevCdromDevices() /*{{{*/ +: libudev_handle(NULL), udev_new(NULL), udev_enumerate_add_match_property(NULL), + udev_enumerate_scan_devices(NULL), udev_enumerate_get_list_entry(NULL), + udev_device_new_from_syspath(NULL), udev_enumerate_get_udev(NULL), + udev_list_entry_get_name(NULL), udev_device_get_devnode(NULL), + udev_enumerate_new(NULL), udev_list_entry_get_next(NULL), + udev_device_get_property_value(NULL), udev_enumerate_add_match_sysattr(NULL) { - } /*}}}*/ -- cgit v1.2.3 From 8fe964f148344b8a55252fe52b6292a4ab86ea98 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 14 Nov 2014 18:01:09 +0100 Subject: create our cache and lib directory always with mode 755 We autocreate for a while now the last two directories in /var/lib/apt/lists (similar for /var/cache/apt/archives) which is very nice for systems having any of those on tmpfs or other non-persistent storage. This also means though that this creation is effected by the default umask, so for people with aggressive umasks like 027 the directories will be created with 750, which means all non-root users are left out, which is usually exactly what we want then this umask is set, but the cache and lib directories contain public knowledge. There isn't any need to protect them from viewers and they render apt completely useless if not readable. --- apt-pkg/cdrom.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'apt-pkg/cdrom.cc') diff --git a/apt-pkg/cdrom.cc b/apt-pkg/cdrom.cc index b97f7b036..aaa7b82e0 100644 --- a/apt-pkg/cdrom.cc +++ b/apt-pkg/cdrom.cc @@ -822,8 +822,11 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/ // check for existence and possibly create state directory for copying string const listDir = _config->FindDir("Dir::State::lists"); string const partialListDir = listDir + "partial/"; - if (CreateAPTDirectoryIfNeeded(_config->FindDir("Dir::State"), partialListDir) == false && - CreateAPTDirectoryIfNeeded(listDir, partialListDir) == false) + mode_t const mode = umask(S_IWGRP | S_IWOTH); + bool const creation_fail = (CreateAPTDirectoryIfNeeded(_config->FindDir("Dir::State"), partialListDir) == false && + CreateAPTDirectoryIfNeeded(listDir, partialListDir) == false); + umask(mode); + if (creation_fail == true) { UnmountCDROM(CDROM, NULL); return _error->Errno("cdrom", _("List directory %spartial is missing."), listDir.c_str()); -- cgit v1.2.3 From 2b4cead3c8eb3afb5aa5390b88c511477a7628d8 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 9 Mar 2015 15:54:39 +0100 Subject: fix some new compiler warnings reported by gcc-5 Git-Dch: Ignore --- apt-pkg/cdrom.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'apt-pkg/cdrom.cc') diff --git a/apt-pkg/cdrom.cc b/apt-pkg/cdrom.cc index aaa7b82e0..5eccbe5de 100644 --- a/apt-pkg/cdrom.cc +++ b/apt-pkg/cdrom.cc @@ -466,7 +466,7 @@ bool pkgCdrom::WriteSourceList(string Name,vector &List,bool Source) // Open the stream for reading ifstream F((FileExists(File)?File.c_str():"/dev/null"), ios::in ); - if (!F != 0) + if (F.fail() == true) return _error->Errno("ifstream::ifstream","Opening %s",File.c_str()); string NewFile = File + ".new"; @@ -477,7 +477,7 @@ bool pkgCdrom::WriteSourceList(string Name,vector &List,bool Source) "Failed to open %s.new",File.c_str()); // Create a short uri without the path - string ShortURI = "cdrom:[" + Name + "]/"; + string ShortURI = "cdrom:[" + Name + "]/"; string ShortURI2 = "cdrom:" + Name + "/"; // For Compatibility string Type; @@ -485,12 +485,12 @@ bool pkgCdrom::WriteSourceList(string Name,vector &List,bool Source) Type = "deb-src"; else Type = "deb"; - + char Buffer[300]; int CurLine = 0; bool First = true; while (F.eof() == false) - { + { F.getline(Buffer,sizeof(Buffer)); CurLine++; if (F.fail() && !F.eof()) @@ -754,7 +754,7 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/ FileExists(InfoDir + "/info") == true) { ifstream F((InfoDir + "/info").c_str()); - if (!F == 0) + if (F.good() == true) getline(F,Name); if (Name.empty() == false) -- cgit v1.2.3 From d84da4995df24329e96d57a22136683a9e370f4e Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 11 Apr 2015 20:13:19 +0200 Subject: ensure lists/ files have correct permissions after apt-cdrom add Its a bit unpredictable which permissons and owners we will encounter on a CD-ROM (or a USB stick, as apt-cdrom is responsible for those too), so we have to ensure in this codepath as well that everything is nicely setup without waiting for a 'apt-get update' to fix up the (potential) mess. --- apt-pkg/cdrom.cc | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'apt-pkg/cdrom.cc') diff --git a/apt-pkg/cdrom.cc b/apt-pkg/cdrom.cc index 5eccbe5de..8cec4b78e 100644 --- a/apt-pkg/cdrom.cc +++ b/apt-pkg/cdrom.cc @@ -927,8 +927,7 @@ pkgUdevCdromDevices::pkgUdevCdromDevices() /*{{{*/ } /*}}}*/ -bool -pkgUdevCdromDevices::Dlopen() /*{{{*/ +bool pkgUdevCdromDevices::Dlopen() /*{{{*/ { // alread open if(libudev_handle != NULL) @@ -957,18 +956,14 @@ pkgUdevCdromDevices::Dlopen() /*{{{*/ return true; } /*}}}*/ - /*{{{*/ -// convenience interface, this will just call ScanForRemovable -vector -pkgUdevCdromDevices::Scan() +// convenience interface, this will just call ScanForRemovable /*{{{*/ +vector pkgUdevCdromDevices::Scan() { bool CdromOnly = _config->FindB("APT::cdrom::CdromOnly", true); return ScanForRemovable(CdromOnly); } /*}}}*/ - /*{{{*/ -vector -pkgUdevCdromDevices::ScanForRemovable(bool CdromOnly) +vector pkgUdevCdromDevices::ScanForRemovable(bool CdromOnly)/*{{{*/ { vector cdrom_devices; struct udev_enumerate *enumerate; -- cgit v1.2.3