if (debug) { if (rv == -1) log_d("check_symlinks: lstat(\"%s\") = %d", b, rv); else log_d("check_symlinks: lstat(\"%s\") = %d; st_mode = %#o", b, rv, buf.st_mode); }
static int check_symlinks(struct request *r){	char *p, *s, *t, b[PATHLEN];	struct control *c;	struct stat buf;	int flag, rv;	p = r->path_translated;	c = r->c;	if (c->symlinksok)		return 0;	strcpy(b, p);	t = b + (c->locations->name ? strlen(c->locations->name) : 0);	s = b + strlen(b);	flag = 1;	while (--s > t) {		if (*s == '/') {			*s = 0;			flag = 1;		} else if (flag) {			flag = 0;			rv = lstat(b, &buf);			if (debug) {				if (rv == -1)					log_d("check_symlinks: lstat(\"%s\") = %d", b, rv);				else					log_d("check_symlinks: lstat(\"%s\") = %d; st_mode = %#o", b, rv, buf.st_mode);			}			if (rv == -1) {				lerror("lstat");				return -1;			}			if (S_ISLNK(buf.st_mode)) {				log_d("%s is a symbolic link", b);					return -1;			}		}	}	return 0;}