Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
darshan
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
72
Issues
72
List
Boards
Labels
Milestones
Merge Requests
5
Merge Requests
5
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
darshan
darshan
Commits
31429ebd
Commit
31429ebd
authored
Sep 21, 2016
by
Shane Snyder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
switch from cuserid to getpwuid for username
parent
5a3d1bdc
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
26 deletions
+24
-26
darshan-runtime/configure.in
darshan-runtime/configure.in
+0
-7
darshan-runtime/darshan-core.h
darshan-runtime/darshan-core.h
+3
-0
darshan-runtime/lib/darshan-core.c
darshan-runtime/lib/darshan-core.c
+21
-19
No files found.
darshan-runtime/configure.in
View file @
31429ebd
...
...
@@ -31,13 +31,6 @@ AC_ARG_ENABLE(ld-preload,
fi]
,)
AC_ARG_ENABLE(cuserid,
[ --disable-cuserid Disables attempted use of cuserid() at run time],
[if test "x$enableval" = "xno" ; then
AC_DEFINE(__DARSHAN_DISABLE_CUSERID, 1, Define if cuserid() should be disabled)
fi]
,)
AC_ARG_ENABLE(group-readable-logs,
[ --enable-group-readable-logs
Set log files to be group readable],
...
...
darshan-runtime/darshan-core.h
View file @
31429ebd
...
...
@@ -51,6 +51,9 @@
/* Default runtime compression buffer size */
#define DARSHAN_COMP_BUF_SIZE DARSHAN_MOD_MEM_MAX
/* Maximum length of a username corresponding to a Darshan log */
#define DARSHAN_USERNAME_LEN_MAX 32
/* structure to track registered modules */
struct
darshan_core_module
{
...
...
darshan-runtime/lib/darshan-core.c
View file @
31429ebd
...
...
@@ -25,6 +25,7 @@
#include <sys/stat.h>
#include <sys/mman.h>
#include <sys/vfs.h>
#include <pwd.h>
#include <zlib.h>
#include <mpi.h>
#include <assert.h>
...
...
@@ -117,7 +118,7 @@ static void darshan_fs_info_from_path(
static
int
darshan_add_name_record_ref
(
struct
darshan_core_runtime
*
core
,
darshan_record_id
rec_id
,
const
char
*
name
,
darshan_module_id
mod_id
);
static
void
darshan_get_user
_
name
(
static
void
darshan_get_username
(
char
*
user
);
static
void
darshan_get_logfile_name
(
char
*
logfile_name
,
int
jobid
,
struct
tm
*
start_tm
);
...
...
@@ -785,7 +786,7 @@ static void *darshan_init_mmap_log(struct darshan_core_runtime* core, int jobid)
int
mmap_fd
;
int
mmap_size
;
int
sys_page_size
;
char
cuser
[
L_cuserid
]
=
{
0
};
char
username
[
DARSHAN_USERNAME_LEN_MAX
]
=
{
0
};
uint64_t
hlevel
;
char
hname
[
HOST_NAME_MAX
];
uint64_t
logmod
;
...
...
@@ -807,7 +808,7 @@ static void *darshan_init_mmap_log(struct darshan_core_runtime* core, int jobid)
else
mmap_log_path
=
DARSHAN_DEF_MMAP_LOG_PATH
;
darshan_get_user
_name
(
cuser
);
darshan_get_user
name
(
username
);
/* generate a random number to help differentiate the temporary log */
/* NOTE: job id is not sufficient for constructing a unique log file name,
...
...
@@ -827,7 +828,7 @@ static void *darshan_init_mmap_log(struct darshan_core_runtime* core, int jobid)
*/
snprintf
(
core
->
mmap_log_name
,
PATH_MAX
,
"/%s/%s_%s_id%d_mmap-log-%"
PRIu64
"-%d.darshan"
,
mmap_log_path
,
cuser
,
__progname
,
jobid
,
logmod
,
my_rank
);
mmap_log_path
,
username
,
__progname
,
jobid
,
logmod
,
my_rank
);
/* create the temporary mmapped darshan log */
mmap_fd
=
open
(
core
->
mmap_log_name
,
O_CREAT
|
O_RDWR
|
O_EXCL
,
0644
);
...
...
@@ -1170,14 +1171,15 @@ static int darshan_add_name_record_ref(struct darshan_core_runtime *core,
return
(
1
);
}
static
void
darshan_get_user
_name
(
char
*
cuser
)
static
void
darshan_get_user
name
(
char
*
username
)
{
struct
passwd
*
pwd
;
char
*
logname_string
;
/* get the username for this job. In order we will try each of the
* following until one of them succeeds:
*
* -
cuserid(
)
* -
getpwuid(geteuid()
)
* - getenv("LOGNAME")
* - snprintf(..., geteuid());
*
...
...
@@ -1185,25 +1187,25 @@ static void darshan_get_user_name(char *cuser)
* work in statically compiled binaries.
*/
#ifndef __DARSHAN_DISABLE_CUSERID
cuserid
(
cuser
);
#endif
pwd
=
getpwuid
(
geteuid
());
if
(
pwd
)
strncpy
(
username
,
pwd
->
pw_name
,
(
DARSHAN_USERNAME_LEN_MAX
-
1
));
/* if
cuser
id() didn't work, then check the environment */
if
(
strcmp
(
cuser
,
""
)
==
0
)
/* if
getpwu
id() didn't work, then check the environment */
if
(
strcmp
(
username
,
""
)
==
0
)
{
logname_string
=
getenv
(
"LOGNAME"
);
if
(
logname_string
)
{
strncpy
(
cuser
,
logname_string
,
(
L_cuserid
-
1
));
strncpy
(
username
,
logname_string
,
(
DARSHAN_USERNAME_LEN_MAX
-
1
));
}
}
/* if
cuser
id() and environment both fail, then fall back to uid */
if
(
strcmp
(
cuser
,
""
)
==
0
)
/* if
getpwu
id() and environment both fail, then fall back to uid */
if
(
strcmp
(
username
,
""
)
==
0
)
{
uid_t
uid
=
geteuid
();
snprintf
(
cuser
,
L_cuserid
,
"%u"
,
uid
);
snprintf
(
username
,
DARSHAN_USERNAME_LEN_MAX
,
"%u"
,
uid
);
}
return
;
...
...
@@ -1222,7 +1224,7 @@ static void darshan_get_logfile_name(char* logfile_name, int jobid, struct tm* s
uint64_t
hlevel
;
char
hname
[
HOST_NAME_MAX
];
uint64_t
logmod
;
char
cuser
[
L_cuserid
]
=
{
0
};
char
username
[
DARSHAN_USERNAME_LEN_MAX
]
=
{
0
};
int
ret
;
/* first, check if user specifies a complete logpath to use */
...
...
@@ -1252,7 +1254,7 @@ static void darshan_get_logfile_name(char* logfile_name, int jobid, struct tm* s
#endif
}
darshan_get_user
_name
(
cuser
);
darshan_get_user
name
(
username
);
/* generate a random number to help differentiate the log */
hlevel
=
DARSHAN_MPI_CALL
(
PMPI_Wtime
)()
*
1000000
;
...
...
@@ -1292,7 +1294,7 @@ static void darshan_get_logfile_name(char* logfile_name, int jobid, struct tm* s
ret
=
snprintf
(
logfile_name
,
PATH_MAX
,
"%s/%s_%s_id%d_%d-%d-%d-%"
PRIu64
".darshan_partial"
,
logpath_override
,
cuser
,
__progname
,
jobid
,
username
,
__progname
,
jobid
,
(
start_tm
->
tm_mon
+
1
),
start_tm
->
tm_mday
,
(
start_tm
->
tm_hour
*
60
*
60
+
start_tm
->
tm_min
*
60
+
start_tm
->
tm_sec
),
...
...
@@ -1311,7 +1313,7 @@ static void darshan_get_logfile_name(char* logfile_name, int jobid, struct tm* s
"%s/%d/%d/%d/%s_%s_id%d_%d-%d-%d-%"
PRIu64
".darshan_partial"
,
logpath
,
(
start_tm
->
tm_year
+
1900
),
(
start_tm
->
tm_mon
+
1
),
start_tm
->
tm_mday
,
cuser
,
__progname
,
jobid
,
username
,
__progname
,
jobid
,
(
start_tm
->
tm_mon
+
1
),
start_tm
->
tm_mday
,
(
start_tm
->
tm_hour
*
60
*
60
+
start_tm
->
tm_min
*
60
+
start_tm
->
tm_sec
),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment