diff src/hotspot/os/posix/os_posix.cpp @ 53553:f7f90fddce02

8211326: add OS user related information to hs_err file Reviewed-by: dholmes, stuefe
author mbaesken
date Thu, 15 Nov 2018 17:08:59 +0100
parents 7ac0ac1e57b6
children 33b8f6f4cdf5
line wrap: on
line diff
--- a/src/hotspot/os/posix/os_posix.cpp	Thu Nov 15 21:53:30 2018 -0800
+++ b/src/hotspot/os/posix/os_posix.cpp	Thu Nov 15 17:08:59 2018 +0100
@@ -37,6 +37,8 @@
 
 #include <dirent.h>
 #include <dlfcn.h>
+#include <grp.h>
+#include <pwd.h>
 #include <pthread.h>
 #include <signal.h>
 #include <sys/mman.h>
@@ -441,6 +443,38 @@
   st->cr();
 }
 
+void os::Posix::print_umask(outputStream* st, mode_t umsk) {
+  st->print((umsk & S_IRUSR) ? "r" : "-");
+  st->print((umsk & S_IWUSR) ? "w" : "-");
+  st->print((umsk & S_IXUSR) ? "x" : "-");
+  st->print((umsk & S_IRGRP) ? "r" : "-");
+  st->print((umsk & S_IWGRP) ? "w" : "-");
+  st->print((umsk & S_IXGRP) ? "x" : "-");
+  st->print((umsk & S_IROTH) ? "r" : "-");
+  st->print((umsk & S_IWOTH) ? "w" : "-");
+  st->print((umsk & S_IXOTH) ? "x" : "-");
+}
+
+void os::Posix::print_user_info(outputStream* st) {
+  unsigned id = (unsigned) ::getuid();
+  st->print("uid  : %u ", id);
+  id = (unsigned) ::geteuid();
+  st->print("euid : %u ", id);
+  id = (unsigned) ::getgid();
+  st->print("gid  : %u ", id);
+  id = (unsigned) ::getegid();
+  st->print_cr("egid : %u", id);
+  st->cr();
+
+  mode_t umsk = ::umask(0);
+  ::umask(umsk);
+  st->print("umask: %04o (", (unsigned) umsk);
+  print_umask(st, umsk);
+  st->print_cr(")");
+  st->cr();
+}
+
+
 bool os::get_host_name(char* buf, size_t buflen) {
   struct utsname name;
   uname(&name);