diff --git a/cpp/utilities.cpp b/cpp/utilities.cpp
index 872894b..cf0c3cf 100644
--- a/cpp/utilities.cpp
+++ b/cpp/utilities.cpp
@@ -13,22 +13,28 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
#include "utilities.h"
#include "/usr/include/archive.h"
#include
-#include
-#include
-#include
-#include
#include
#include
-#include
-#include
-#include
-#include
-#include
-#include
bool verbose = false;
@@ -442,6 +448,16 @@ void create_tarball(const std::string &tarball_path,
std::string top_dir = base_dir_str + "/";
struct stat file_stat;
if (stat(top_dir.c_str(), &file_stat) == 0) {
+ if (struct passwd *pw = getpwuid(file_stat.st_uid)) {
+ if (char *name = (char *)malloc(strlen(pw->pw_name) + 1)) {
+ archive_entry_set_uname(entry, name);
+ }
+ }
+ if (struct group *gr = getgrgid(file_stat.st_gid)) {
+ if (char *name = (char *)malloc(strlen(gr->gr_name) + 1)) {
+ archive_entry_set_gname(entry, name);
+ }
+ }
archive_entry_set_uid(entry, file_stat.st_uid);
archive_entry_set_gid(entry, file_stat.st_gid);
archive_entry_set_perm(entry, file_stat.st_mode);
@@ -513,6 +529,16 @@ void create_tarball(const std::string &tarball_path,
struct stat file_stat;
if (stat(path.c_str(), &file_stat) == 0) {
+ if (struct passwd *pw = getpwuid(file_stat.st_uid)) {
+ if (char *name = (char *)malloc(strlen(pw->pw_name) + 1)) {
+ archive_entry_set_uname(entry, name);
+ }
+ }
+ if (struct group *gr = getgrgid(file_stat.st_gid)) {
+ if (char *name = (char *)malloc(strlen(gr->gr_name) + 1)) {
+ archive_entry_set_gname(entry, name);
+ }
+ }
archive_entry_set_uid(entry, file_stat.st_uid);
archive_entry_set_gid(entry, file_stat.st_gid);
archive_entry_set_perm(entry, file_stat.st_mode);