📄 shadow_pass.c
字号:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <fcntl.h>
#include <shadow.h>
main()
{
FILE *fp;
char buf[1000];
int i,j;
char *ptr;
struct spwd sha;
struct spwd *shaptr;
printf("显示shadow文件的内容\n");
if((fp=fopen("shadow","r"))==NULL)
{
printf("Cannot open shadow file.\n");
exit(1);
}
j=0;
while(!feof(fp))
{
if(fgets(buf,1000,fp)==NULL)
{
printf("Read shadow file error!\n");
exit(-1);
}
ptr=strchr(buf,':');
*ptr=0;
shaptr=getspnam(buf);
if(shaptr==NULL)
{
printf("null!!\n");
exit(-1);
}
printf("用户名:%s\n",shaptr->sp_namp);
printf("密码:%s\n",shaptr->sp_pwdp);
printf("过期日:%d\n",shaptr->sp_expire);
printf("***************\n");
j++;
}
printf("总用户数:%d\n",j);
printf("结束\n");
exit(0);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -