免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 4129 | 回复: 1
打印 上一主题 下一主题

[Tru64 UNIX] Tru64-FAQ-Security [复制链接]

论坛徽章:
1
荣誉版主
日期:2011-11-23 16:44:17
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2003-04-04 18:03 |只看该作者 |倒序浏览
Tru64-FAQ-Security
Security 1 -- How do I authenticate users on Tru64 UNIX?

Perhaps a bit of background first - generally the question is related to C2 or Enhanced Security, but the question always boils down to how can I take a given username and password and authenticate a user. Generally, this would be a combination of:


    pwd = getpwnam(username);
    if (strcmp(pwd->;pw_passwd, crypt(password, pwd->;pw_passwd)) == 0)
        return success;
    return fail;

The above assumes char *username and char *password are filled in with "precollected" username and password...
The problem/issue with this method is that for Enhanced Security configurations the pwd->;pw_passwd field contains an asterisk ("*" and the password is actually stored in another database (/tcb/files/auth.db or /var/tcb/files/auth.db). In addition, the password found in those databases may not have been encrypted using the crypt() function.

Tru64 UNIX solves this by providing a general purpose function "sia_validate_user()" which will accept as parameters the username and password and perform the user authentication for you regardless of the security mechanism that is in place. Using the sia_validate_user() function relieves the programmer of needing to know what security mechanism is being used on the target Tru64 UNIX system.

The following is a code example which can be compiled and run as its own image or can be fit into an existing application which performs the getpwnam() and crypt() calls.


% cat siavaluser.c
#include
#include
#include
#include
#include

int main(int argc, char *argv[])
{
int myargc = 1;
char *myargv[2];
char *user   = "someusername";
char *pass   = "yourpassword";
int auth_stat;

myargv[0] = "yourapplicationname";
myargv[1] = NULL;

set_auth_parameters(argc, argv);

    if (argc != 3) {
        fprintf(stderr, "usage: %s username password
", argv[0]);
        exit(1);
    }

    user = argv[1];
    pass = argv[2];

auth_stat =
sia_validate_user(NULL,myargc,myargv,NULL,user,NULL,0,NULL,pass);

if (auth_stat != SIASUCCESS ) {
printf("No go %d", errno);
perror("";
}
printf ("Done
";
}

% cc -g -o siavaluser siavaluser.c -lsecurity
% ./siavaluser username password

论坛徽章:
0
2 [报告]
发表于 2004-11-26 21:40 |只看该作者

Tru64-FAQ-Security

set_auth_parameters(argc, argv); 这个函数是做什么用的?什么功能?
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP