src/apache2_module/Config.cpp in passenger-5.3.3 vs src/apache2_module/Config.cpp in passenger-5.3.4

- old
+ new

@@ -1,8 +1,8 @@ /* * Phusion Passenger - https://www.phusionpassenger.com/ - * Copyright (c) 2010-2017 Phusion Holding B.V. + * Copyright (c) 2010-2018 Phusion Holding B.V. * * "Passenger", "Phusion Passenger" and "Union Station" are registered * trademarks of Phusion Holding B.V. * * Permission is hereby granted, free of charge, to any person obtaining a copy @@ -45,10 +45,11 @@ #include "ConfigGeneral/ManifestGeneration.h" #include "DirConfig/AutoGeneratedCreateFunction.cpp" #include "DirConfig/AutoGeneratedMergeFunction.cpp" #include "Utils.h" #include <JsonTools/Autocast.h> +#include <SystemTools/UserDatabase.h> #include <Utils.h> #include <Constants.h> // The APR headers must come after the Passenger headers. // See Hooks.cpp to learn why. @@ -129,28 +130,28 @@ } void postprocessConfig(server_rec *s, apr_pool_t *pool, apr_pool_t *temp_pool) { if (serverConfig.defaultGroup.empty()) { - struct passwd *userEntry = getpwnam(serverConfig.defaultUser.c_str()); - if (userEntry == NULL) { + OsUser osUser; + if (!lookupSystemUserByName(serverConfig.defaultUser, osUser)) { throw ConfigurationException( "The user that PassengerDefaultUser refers to, '" + serverConfig.defaultUser + "', does not exist."); } - struct group *groupEntry = getgrgid(userEntry->pw_gid); - if (groupEntry == NULL) { + OsGroup osGroup; + if (!lookupSystemGroupByGid(osUser.pwd.pw_gid, osGroup)) { throw ConfigurationException( "The option PassengerDefaultUser is set to '" + serverConfig.defaultUser + "', but its primary group doesn't exist. " "In other words, your system's user account database " "is broken. Please fix it."); } - serverConfig.defaultGroup = apr_pstrdup(pool, groupEntry->gr_name); + serverConfig.defaultGroup = apr_pstrdup(pool, osGroup.grp.gr_name); } serverConfig.manifest = ConfigManifestGenerator(s, temp_pool).execute(); if (!serverConfig.dumpConfigManifest.empty()) {