348 lines
8.9 KiB
HTML
348 lines
8.9 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
<meta name="Copyright" content="Copyright (c) 2006 by IBM Corporation">
|
|
<title>QlgGetpwuid_r()--Get User Information for User ID (using NLS-enabled
|
|
path name)</title>
|
|
<!-- Begin Header Records -->
|
|
<!-- All rights reserved. Licensed Materials Property of IBM -->
|
|
<!-- US Government Users Restricted Rights -->
|
|
<!-- Use, duplication or disclosure restricted by -->
|
|
<!-- GSA ADP Schedule Contract with IBM Corp. -->
|
|
<!-- Change History: -->
|
|
<!-- file cleaned -->
|
|
<!-- Created for V5R1-->
|
|
<!-- This file has undergone html cleanup June 2002 by JET -->
|
|
<link rel="stylesheet" type="text/css" href="../rzahg/ic.css">
|
|
</head>
|
|
<body>
|
|
<!-- End Header Records --><!--Java sync-link-->
|
|
<script language="Javascript" src="../rzahg/synch.js" type="text/javascript">
|
|
</script>
|
|
|
|
<a name="Top_Of_Page"></a>
|
|
|
|
<h2>QlgGetpwuid_r()--Get User Information for User ID (using NLS-enabled path
|
|
name)</h2>
|
|
|
|
<div class="box" style="width: 60%;">
|
|
<br>
|
|
Syntax<br>
|
|
|
|
|
|
<pre>
|
|
#include <sys/types.h>
|
|
#include <pwd.h>
|
|
|
|
int QlgGetpwuid_r(uid_t <em>uid</em>,
|
|
struct qplg_passwd <em>*pwd</em>,
|
|
char <em>*buffer</em>,
|
|
size_t <em>bufsize</em>,
|
|
struct qplg_passwd <em>**result</em>);
|
|
</pre>
|
|
|
|
Service Program Name: QSYPAPI<br>
|
|
<!-- iddvc RMBR -->
|
|
<br>
|
|
Default Public Authority: *USE<br>
|
|
<!-- iddvc RMBR -->
|
|
<br>
|
|
Threadsafe: Yes<br>
|
|
<!-- iddvc RMBR -->
|
|
<br>
|
|
</div>
|
|
|
|
<p>The <strong>QlgGetpwuid_r()</strong> function updates the <em>
|
|
qplg_passwd</em> structure pointed to by <em>pwd</em> and stores a pointer to
|
|
that structure in the location pointed to by <em>result</em>. The structure
|
|
contains an entry from the user database with a matching <em>UID</em>.</p>
|
|
|
|
<br>
|
|
<h3>Parameters</h3>
|
|
|
|
<dl>
|
|
<dt><strong><em>UID</em></strong></dt>
|
|
|
|
<dd>(Input) A pointer to a user ID.<br>
|
|
</dd>
|
|
|
|
<dt><strong><em>pwd</em></strong></dt>
|
|
|
|
<dd>(Input) A pointer to a struct qplg_passwd.<br>
|
|
</dd>
|
|
|
|
<dt><strong><em>buffer</em></strong></dt>
|
|
|
|
<dd>(Input) A pointer to a buffer from which memory is allocated to hold
|
|
storage areas referenced by the structure qplg_passwd.<br>
|
|
</dd>
|
|
|
|
<dt><strong><em>bufsize</em></strong></dt>
|
|
|
|
<dd>(Input) The size of <em>buffer</em> in bytes.<br>
|
|
</dd>
|
|
|
|
<dt><strong><em>result</em></strong></dt>
|
|
|
|
<dd>(Input) A pointer to a location in which a pointer to the updated
|
|
qplg_passwd structure is stored. If an error occurs or if the requested entry
|
|
cannot be found, a NULL pointer is stored in this location.<br>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>The <samp>struct qplg_passwd</samp>, which is defined in the <strong>
|
|
pwd.h</strong> header file, has the following elements:</p>
|
|
|
|
<table border width="100%">
|
|
<tr>
|
|
<td align="left" valign="top" width="25%">char *</td>
|
|
<td align="left" valign="top" width="20%">pw_name</td>
|
|
<td align="left" valign="top" width="55%">User name</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top">uid_t</td>
|
|
<td align="left" valign="top">pw_uid</td>
|
|
<td align="left" valign="top">User ID</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top">uid_t</td>
|
|
<td align="left" valign="top">pw_gid</td>
|
|
<td align="left" valign="top">Group ID</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top">Qlg_Path_Name_T</td>
|
|
<td align="left" valign="top">pw_dir</td>
|
|
<td align="left" valign="top">Initial working directory</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top">char *</td>
|
|
<td align="left" valign="top">pw_shell</td>
|
|
<td align="left" valign="top">Initial user program</td>
|
|
</tr>
|
|
</table>
|
|
|
|
<p>See <a href="gtpwuidr.htm">getpwuid_r()--Get User Information for User
|
|
ID</a> for more on the <em>pwd</em>, <em>result</em> and other parameters.</p>
|
|
|
|
<br>
|
|
<h3>Authorities</h3>
|
|
|
|
<p>*READ authority is required to the user profile associated with the <em>
|
|
UID</em>.</p>
|
|
|
|
<br>
|
|
<h3>Return Value</h3>
|
|
|
|
<dl>
|
|
<dt><em>0</em></dt>
|
|
|
|
<dd><strong>QlgGetpwuid_r()</strong> was successful.<br>
|
|
<br>
|
|
</dd>
|
|
|
|
<dt><em>Any other value</em></dt>
|
|
|
|
<dd>Failure: The return value contains an error number indicating the
|
|
error.</dd>
|
|
</dl>
|
|
|
|
<br>
|
|
<h3>Error Conditions</h3>
|
|
|
|
<p>If <strong>QlgGetpwuid_r()</strong> is not successful, the error value
|
|
usually indicates one of the following errors. Under some conditions, the value
|
|
could indicate an error other than those listed here.</p>
|
|
|
|
<table cellpadding="5">
|
|
<!-- cols="25 75" -->
|
|
|
|
<tr>
|
|
<th align="left" valign="bottom">Error condition</th>
|
|
<th align="left" valign="bottom">Additional information</th>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top">
|
|
<em>[<a href="unix14.htm#EAGAIN">EAGAIN</a>]</em></td>
|
|
|
|
<td align="left" valign="top">
|
|
<p>The user profile associated with the <em>uid</em> is currently locked by
|
|
another process.</p>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top">
|
|
<em>[<a href="unix14.htm#EC2">EC2</a>]</em></td>
|
|
|
|
<td align="left" valign="top">
|
|
<p>Detected pointer that is not valid.</p>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top">
|
|
<em>[<a href="unix14.htm#EINVAL">EINVAL</a>]</em></td>
|
|
|
|
<td align="left" valign="top">
|
|
<p>Value is not valid. Check the job log for messages.</p>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top">
|
|
<em>[<a href="unix14.htm#ENOENT">ENOENT</a>]</em></td>
|
|
|
|
<td align="left" valign="top">
|
|
<p>The user profile associated with <em>UID</em> was not found.</p>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top">
|
|
<em>[<a href="unix14.htm#ENOMEM">ENOMEM</a>]</em></td>
|
|
|
|
<td align="left" valign="top">
|
|
<p>The user profile associated with the <em>UID</em> has exceeded its storage
|
|
limit or is unable to allocate memory.</p>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td align="left" valign="top">
|
|
<em>[<a href="unix14.htm#ENOSPC">ENOSPC</a>]</em></td>
|
|
|
|
<td align="left" valign="top">
|
|
<p>Machine storage limit exceeded.</p>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top">
|
|
<em>[<a href="unix14.htm#EPERM">EPERM</a>]</em></td>
|
|
|
|
<td align="left" valign="top">
|
|
<p>The calling job does not have *READ authority to the user profile
|
|
associated with the <em>UID</em>.</p>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top">
|
|
<em>[<a href="unix14.htm#ERANGE">ERANGE</a>]</em></td>
|
|
|
|
<td align="left" valign="top">
|
|
<p>Insufficient storage was supplied through <em>buffer</em> and <em>
|
|
bufsize</em> to contain the data to be referenced by the resulting group
|
|
structure.</p>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top">
|
|
<em>[<a href="unix14.htm#EUNKNOWN">EUNKNOWN</a>]</em></td>
|
|
|
|
<td align="left" valign="top">
|
|
<p>Unknown system state. Check the job log for a CPF9872 message. If there is
|
|
no message, verify that the home directory field in the user profile can be
|
|
displayed.</p>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
|
|
<br>
|
|
<h3>Usage Notes</h3>
|
|
|
|
<p>The path name is returned in the default IFS UNICODE CCSID.</p>
|
|
|
|
<br>
|
|
<h3>Related Information</h3>
|
|
|
|
<ul>
|
|
<li>The <<strong>pwd.h</strong>> file (see <a href="unix13.htm">Header
|
|
Files for UNIX-Type Functions</a>)
|
|
<br>
|
|
</li>
|
|
|
|
<li><a href="getpwuid.htm">getpwuid()</a>--Get User Information for User ID<br>
|
|
</li>
|
|
|
|
<li><a href="gtpwuidr.htm">getpwuid_r()</a>--Get User Information for User
|
|
ID<br>
|
|
</li>
|
|
|
|
<li><a href="getpwuidu.htm">QlgGetpwuid()</a>--Get User Information for User ID
|
|
(using NLS-enabled path name)</li>
|
|
</ul>
|
|
|
|
<br>
|
|
<h3>Example</h3>
|
|
|
|
<p>See <a href="../apiref/aboutapis.htm#codedisclaimer">Code disclaimer information</a>
|
|
for information pertaining to code examples.</p>
|
|
|
|
<p>The following example gets the user database information for the uid of 22.
|
|
The user name is MYUSER. The GID is 1012. The intial working directory is
|
|
/home/MYUSER. The initial user program is *LIBL/QCMD.</p>
|
|
|
|
<pre>
|
|
#include <sys/types.h>
|
|
#include <pwd.h>
|
|
#include <stdio.h>
|
|
#include <errno.h>
|
|
|
|
main()
|
|
{
|
|
struct qplg_passwd pd;
|
|
passwd ** tempPwdPtr;
|
|
char pwdbuffer[200];
|
|
int pwdlinelen = sizeof(pwdbuffer);
|
|
|
|
if ((QlgGetpwuid_r(22,&pd,pwdbuffer,pwdlinelen,tempPwdPtr))!=0)
|
|
perror("QlgGetpwuid_r() error.");
|
|
else
|
|
{
|
|
printf("\nThe user name is: %s\n", pd->pw_name);
|
|
printf("The user id is: %u\n", pd->pw_uid);
|
|
printf("The group id is: %u\n", pd->pw_gid);
|
|
printf("The initial working directory length is: %d\n",
|
|
pd->pw_dir->Path_Length);
|
|
printf("The initial working directory CCSID is : %d\n",
|
|
pd->pw_dir->CCSID);
|
|
printf("The initial user program is: %s\n", pd->pw_shell);
|
|
}
|
|
|
|
}
|
|
</pre>
|
|
|
|
<p><strong>Output:</strong></p>
|
|
|
|
<pre>
|
|
The user name is: MYUSER
|
|
The user ID is: 22
|
|
The group ID is: 0
|
|
The initial working directory length is: 24
|
|
The initial working directory CCSID is : 13488
|
|
The initial user program is: *LIBL/QCMD
|
|
</pre>
|
|
|
|
<hr>
|
|
API introduced: V5R1
|
|
|
|
<hr>
|
|
<center>
|
|
<table cellpadding="2" cellspacing="2">
|
|
<tr align="center">
|
|
<td valign="middle" align="center"><a href="#Top_Of_Page">Top</a> | <a href=
|
|
"unix.htm">UNIX-Type APIs</a> | <a href="aplist.htm">APIs by category</a></td>
|
|
</tr>
|
|
</table>
|
|
</center>
|
|
</body>
|
|
</html>
|
|
|