gpt4 book ai didi

c - 将 AIX 特定的 C 函数调用迁移到 Linux

转载 作者:太空宇宙 更新时间:2023-11-04 10:00:01 25 4
gpt4 key购买 nike

我从 IBM AIX 上的一个应用程序中获得了源文件,我正在尝试在 Linux 上构建它们。但是,在 AIX 上名为 usersec.huserpw.h 的头文件在 Linux 上不存在。因此,在 Linux 上,我收到这些函数的编译器错误:

usersec.h中声明

int     getuserattr (char *, char *, void *, int);

关于 getuserattr 的更多信息是 here

userpw.h中声明

struct userpw
{
char *upw_passwd; /* user's passwd */
unsigned int upw_flags; /* flags of restrictions */
time_t upw_lastupdate; /* date of last passwd update */
char upw_name[PW_NAMELEN]; /* user's name */
};

struct userpw *getuserpw ();
int setpwdb ();
int endpwdb ();

请查找更多信息:getuserpw , setpwdb and endpwdb

如果有人知道如何在 Linux 上编写等效函数,那就太好了。

最佳答案

您可能想使用 getpwent , 及其相关函数。

The getpwent() function returns a pointer to a structure containing the broken-out fields of a record from the password database (e.g., the local password file /etc/passwd, NIS, and LDAP). The first time getpwent() is called, it returns the first entry; thereafter, it returns successive entries.

The setpwent() function rewinds to the beginning of the password database.

The endpwent() function is used to close the password database after all processing has been performed.

如果你想得到特定用户的密码条目,你可以使用getpwnam或其变体之一。

The getpwnam() function returns a pointer to a structure containing the broken-out fields of the record in the password database (e.g., the local password file /etc/passwd, NIS, and LDAP) that matches the username name.

关于c - 将 AIX 特定的 C 函数调用迁移到 Linux,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57062930/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com