level 8
pqy330
楼主
我搞了个内核+busybox的基本系统,想给他加上ssh,因为连glibc都没有,所以最开始的想法当然是静态编译openssh了,但是发现不能用,输入ssh只是丢出一句“No user exists for uid 0”,google“No user exists for uid”,竟然没有任何匹配,难以置信。于是在openssh源码目录搜索“No user exists for uid”,发现打印这句话的原因是调用getpwuid(getuid())时返回NULL。
于是搞了这么个测试代码:
#include <pwd.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
int main(){
struct passwd* pw;
uid_t u;
u=getuid();
printf("%u\n",u);
pw = getpwuid(getuid());
if(pw == NULL)
printf("pw is NULL pointer.\n");
else
printf("pw isnot NULL pointer.\n");
return 0;
}
发现当我动态链接时,打印的是“pw isnot NULL pointer.",改为静态链接时,打印的却是”pw is NULL pointer.",并且静态编译会有警告:Using 'getpwuid' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking。
如果我一定要静态链接,那应该怎么搞?
2014年05月20日 02点05分
1
于是搞了这么个测试代码:
#include <pwd.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
int main(){
struct passwd* pw;
uid_t u;
u=getuid();
printf("%u\n",u);
pw = getpwuid(getuid());
if(pw == NULL)
printf("pw is NULL pointer.\n");
else
printf("pw isnot NULL pointer.\n");
return 0;
}
发现当我动态链接时,打印的是“pw isnot NULL pointer.",改为静态链接时,打印的却是”pw is NULL pointer.",并且静态编译会有警告:Using 'getpwuid' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking。
如果我一定要静态链接,那应该怎么搞?