Skip to content

Commit

Permalink
Fix of #3969 (crash if $USER is not set)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasmatena committed Sep 22, 2021
1 parent ef800a8 commit d57d3f9
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/slic3r/GUI/RemovableDriveManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,7 @@ namespace search_for_drives_internal
struct stat buf;
stat(path.c_str(), &buf);
uid_t uid = buf.st_uid;
std::string username(std::getenv("USER"));
struct passwd *pw = getpwuid(uid);
if (pw != 0 && pw->pw_name == username)
if (getuid() == uid)
out.emplace_back(DriveData{ boost::filesystem::basename(boost::filesystem::path(path)), path });
}
}
Expand Down Expand Up @@ -245,7 +243,7 @@ std::vector<DriveData> RemovableDriveManager::search_for_removable_drives() cons
search_for_drives_internal::search_path("/media/*", "/media", current_drives);

//search_path("/Volumes/*", "/Volumes");
std::string path(std::getenv("USER"));
std::string path = wxGetUserId().ToUTF8().data();
std::string pp(path);

//search /media/USERNAME/* folder
Expand Down

0 comments on commit d57d3f9

Please sign in to comment.