convert.c
资源名称:httpd.tar.gz [点击查看]
上传用户:lampled
上传日期:2007-01-07
资源大小:94k
文件大小:1k
源码类别:
Web服务器
开发平台:
Unix_Linux
- /* Copyright (C) 1995, 1996 by Sven Berkvens (sven@stack.nl) */
- #include "config.h"
- #include <pwd.h>
- #include <stdio.h>
- #include <sys/stat.h>
- #include "httpd.h"
- #include "local.h"
- #include "string.h"
- extern const char *
- convertpath DECL1C(char *, orig)
- {
- static char buffer[XS_PATH_MAX];
- const struct passwd *userinfo;
- char person[32];
- if (!strncmp(orig, "/~", 2))
- {
- strncpy(person, orig + 2, 31);
- person[31] = 0;
- strtok(person, "/");
- if (!(userinfo = getpwnam(person)))
- strcpy(buffer, "UNKNOWN_USER");
- else if (transform_user_dir(buffer, userinfo, 0))
- strcpy(buffer, "PERMISSION_DENIED");
- strncat(buffer, orig + 3 + strlen(person), XS_PATH_MAX - 64);
- } else
- strncpy(buffer, orig, XS_PATH_MAX - 1);
- buffer[XS_PATH_MAX - 1] = 0;
- return(buffer);
- }