示例#1
0
int
lookup_passwd(const char *local)
{
	char username[GETPW_USERLEN];
	struct stat st;
	const char *extension;
	struct passwd *pw;


	extension = local + str_len(local);
	for (; extension >= local; extension--) {
		if ((unsigned long)(extension - local) < sizeof(username))
			if (!*extension || (*extension == *auto_break)) {
				byte_copy(username, extension - local, local);
				username[extension - local] = 0;
				case_lowers(username);
				errno = 0;
				pw = getpwnam(username);
				if (errno == error_txtbsy)
					return temp_sys();
				if (pw && pw->pw_uid != 0) {
					if (stat(pw->pw_dir,&st) == 0 &&
					    st.st_uid == pw->pw_uid) {
						/* OK */
						if (substdio_putflush(subfdout,
						    "K", 1) == -1)
							die_write();
						return (1);
					} else if (error_temp(errno))
						return temp_nfs();
				}
			}
	}
	return (0);
}
示例#2
0
文件: ftp.cpp 项目: dv0rak/socketpp
std::string FTP::_readAnswer()
{
    std::string msg;
    _sock.recv(msg, BUFSIZ);

    int code = atoi(msg.substr(0,3).c_str());
    if(code<=100 || code>=599) throw error_proto(msg);
    if(code<=599 && code>=500) throw error_perm(code, msg);
    if(code<=499 && code>=400) throw error_temp(code, msg);
    
    return msg;
}
unsigned int rrandom_read (rrandom_ref z, char *s, unsigned int n, unsigned int (*f) (unirandom_ref, char *, unsigned int))
{
  unsigned int i = 0 ;
  for (; i < 3 ; i++)
  {
    int r ;
    if (!z->tries[i].ok) continue ;
    r = sanitize_read((*f)(&z->tries[i].it, s, n)) ;
    if (r > 0) return r ;
    z->tries[i].ok = error_temp(errno) ? z->tries[i].ok - 1 : 0 ;
  }
  return (errno = ENOENT, 0) ;
}