Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 4 additions & 17 deletions tcl/tcl_directory.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,23 +62,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
************************************************************************/

static int doFull(char **output, int nid, unsigned char nodeUsage, int version);
static char *mds_owner( /* Return: ptr to "user" string */
unsigned int owner /* <r> owner id */
)
/// @param uid - user id
/// @return ptr to "user" string
static char *mds_owner(unsigned int uid)
{
static char ownerString[512];
int gid = owner >> 16;
int uid = owner & 0xFFFF;
char *groupname = 0;
char *username = 0;
#ifdef HAVE_GETGRGID
struct group *g = getgrgid(gid);
if (g)
{
groupname = alloca(strlen(g->gr_name) + 3);
sprintf(groupname, "(%s)", g->gr_name);
}
#endif
#ifdef HAVE_GETPWUID
struct passwd *p = getpwuid(uid);
if (p)
Expand All @@ -87,11 +76,9 @@ static char *mds_owner( /* Return: ptr to "user" string
sprintf(username, "(%s)", p->pw_name);
}
#endif
if (groupname == 0)
groupname = "";
if (username == 0)
username = "";
sprintf(ownerString, "gid=%d%s,uid=%d%s", gid, groupname, uid, username);
sprintf(ownerString, "uid=%d%s", uid, username);
return (ownerString);
}

Expand Down
2 changes: 1 addition & 1 deletion tditest/testing/test-treeshr.ans
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ getnci(.subtree:a12,"parent_relationship")
getnci(.subtree:a12,"get_flags")
128LU
getnci(.subtree:a12,"owner_id")
4194368LU
64LU
getnci(.subtree:a12,"status")
0LU
getnci(.subtree:a12,"brother")
Expand Down
7 changes: 6 additions & 1 deletion treeshr/TreeGetNci.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,12 @@ int TreeGetNci(int nid_in, struct nci_itm *nci_itm)
break_on_no_node;
read_nci;
set_retlen(sizeof(nci.owner_identifier));
*(unsigned int *)itm->pointer = nci.owner_identifier;
unsigned int owner = nci.owner_identifier;
if (!(nci.flags2 & NciM_32BIT_UID_NCI))
{
owner &= 0xFFFF;
}
*(unsigned int *)itm->pointer = owner;
break;
case NciCLASS:
break_on_no_node;
Expand Down
17 changes: 13 additions & 4 deletions treeshr/TreePutRecord.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,23 @@ int _TreePutRecord(void *dbid, int nid, struct descriptor *descriptor_ptr,
int nidx;
unsigned int old_record_length = 0;
static int saved_uic = 0;
static int saved_uic32 = 0;
int shot_open;
EXTENDED_ATTRIBUTES attributes;
int extended = 0;
int64_t extended_offset;
int compress_utility = utility_update == 2;
#ifndef _WIN32
if (!saved_uic)
saved_uic = (getgid() << 16) | getuid();
#endif
{
saved_uic = getuid();
saved_uic32 = (saved_uic & 0xFFFF0000) != 0;
if (!saved_uic32)
{
saved_uic = (getgid() << 16) | (saved_uic);
}
}
#endif
if (!(IS_OPEN(dblist)))
return TreeNOT_OPEN;
if (dblist->open_readonly)
Expand Down Expand Up @@ -181,13 +189,14 @@ int _TreePutRecord(void *dbid, int nid, struct descriptor *descriptor_ptr,
TREETHREADSTATIC_INIT;
local_nci.flags = TREE_TEMPNCI.flags;
bitassign(0, local_nci.flags, NciM_VERSIONS);
bitassign((TREE_TEMPNCI.flags2 & NciM_32BIT_UID_NCI), local_nci.flags2, NciM_32BIT_UID_NCI);
local_nci.owner_identifier = TREE_TEMPNCI.owner_identifier;
local_nci.time_inserted = TREE_TEMPNCI.time_inserted;
}
else
{
bitassign(dblist->setup_info, local_nci.flags,
NciM_SETUP_INFORMATION);
bitassign(dblist->setup_info, local_nci.flags, NciM_SETUP_INFORMATION);
bitassign(saved_uic32, local_nci.flags2, NciM_32BIT_UID_NCI);
local_nci.owner_identifier = saved_uic;
/* VMS time = unixtime * 10,000,000 + 0x7c95674beb4000q */
local_nci.time_inserted = TreeTimeInserted();
Expand Down
21 changes: 19 additions & 2 deletions treeshr/TreeSegments.c
Original file line number Diff line number Diff line change
Expand Up @@ -985,20 +985,37 @@ inline static int begin_finish(vars_t *vars)

#ifndef _WIN32
static int saved_uic = 0;
static void init_saved_uic() { saved_uic = (getgid() << 16) | getuid(); }
static int saved_uic32 = 0;
static void init_saved_uic() {
if (!saved_uic)
{
saved_uic = getuid();
saved_uic32 = (saved_uic & 0xFFFF0000) != 0;
if (!saved_uic32)
{
saved_uic = (getgid() << 16) | (saved_uic);
}
}
}
#endif
inline static void begin_local_nci(vars_t *vars,
const mdsdsc_a_t *initialValue)
{
vars->local_nci.flags2 &= ~NciM_DATA_IN_ATT_BLOCK;
// reset flag2 bits
vars->local_nci.flags2 &= ~(NciM_DATA_IN_ATT_BLOCK | NciM_32BIT_UID_NCI);
vars->local_nci.dtype = initialValue->dtype;
vars->local_nci.class = CLASS_R;
vars->local_nci.time_inserted = TreeTimeInserted();
#ifndef _WIN32
RUN_FUNCTION_ONCE(init_saved_uic);
#else
const int saved_uic = 0;
const int saved_uic32 = 0;
#endif
if (saved_uic32)
{
vars->local_nci.flags2 |= NciM_32BIT_UID_NCI;
}
vars->local_nci.owner_identifier = saved_uic;
}

Expand Down
2 changes: 2 additions & 0 deletions treeshr/treeshrp.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
#define NciV_NON_VMS 3
#define NciM_EXTENDED_NCI 0x10
#define NciV_EXTENDED_NCI 4
#define NciM_32BIT_UID_NCI 0x20
#define NciV_32BIT_UID_NCI 5

typedef struct nci
{
Expand Down