1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
|
/****************************************************************
* *
* Copyright (c) 2001-2018 Fidelity National Information *
* Services, Inc. and/or its subsidiaries. All rights reserved. *
* *
* This source code contains the intellectual property *
* of its copyright holder(s), and is made available *
* under a license. If you do not know the terms of *
* the license, please stop and do not read further. *
* *
****************************************************************/
#include "mdef.h"
#include "gtm_pwd.h"
#include "gtm_unistd.h"
#include "gtm_stdio.h"
#include "gtm_time.h"
#include "gtm_string.h"
#include <errno.h>
#include "gdsroot.h"
#include "gdsbt.h"
#include "gtm_facility.h"
#include "fileinfo.h"
#include "gdsfhead.h"
#include "filestruct.h"
#include "jnl.h"
#ifdef UTF8_SUPPORTED
#include "gtm_icu_api.h" /* needed by *TYPEMASK* macros defined in gtm_utf8.h */
#include "gtm_utf8.h"
#endif
GBLREF uint4 process_id;
GBLREF boolean_t gtm_utf8_mode;
void jnl_prc_vector (jnl_process_vector *pv)
{
unsigned char *c, *s, *ptrstart, *ptrend, *ptrinvalidbegin;
struct passwd *pw;
uid_t eff_uid; /* try to see why gets pwuid == nil */
int gethostname_res;
time_t temp_time;
memset(pv, 0, SIZEOF(jnl_process_vector));
pv->jpv_pid = process_id;
time(&temp_time);
pv->jpv_time = temp_time;
GETHOSTNAME(pv->jpv_node, JPV_LEN_NODE, gethostname_res);
eff_uid = geteuid(); /* save results of each step */
errno = 0; /* force to known value per man page */
GETPWUID(eff_uid, pw);
if (pw)
{
SNPRINTF(pv->jpv_user, JPV_LEN_USER, "%s", pw->pw_name);
SNPRINTF(pv->jpv_prcnam, JPV_LEN_PRCNAM, "%s", pw->pw_name);
# ifdef UTF8_SUPPORTED
/* In UTF8 mode, trim the string (if necessary) to contain only as many valid multi-byte characters as can fit in */
if (gtm_utf8_mode)
{
gtm_utf8_trim_invalid_tail((unsigned char *)pv->jpv_user, JPV_LEN_USER);
gtm_utf8_trim_invalid_tail((unsigned char *)pv->jpv_prcnam, JPV_LEN_PRCNAM);
}
# endif
} else
{
# ifdef DEBUG
SNPRINTF(pv->jpv_user, JPV_LEN_USER, "ERROR=%d", (errno < 1000) ? errno : 1000);
# endif
}
endpwent(); /* close passwd file to free channel */
if ((c = (unsigned char *)TTYNAME(0)) != NULL)
{ /* Get basename for tty */
for (s = c + strlen((char*)c); s > c; --s)
{
if (*s == '/')
{
++s;
break;
}
}
SNPRINTF(pv->jpv_terminal, JPV_LEN_TERMINAL, "%s", (char *)s);
}
}
|