git

Форк
0
/
access.c 
31 строка · 669.0 Байт
1
#define COMPAT_CODE_ACCESS
2
#include "../git-compat-util.h"
3

4
/* Do the same thing access(2) does, but use the effective uid,
5
 * and don't make the mistake of telling root that any file is
6
 * executable.  This version uses stat(2).
7
 */
8
int git_access(const char *path, int mode)
9
{
10
	struct stat st;
11

12
	/* do not interfere a normal user */
13
	if (geteuid())
14
		return access(path, mode);
15

16
	if (stat(path, &st) < 0)
17
		return -1;
18

19
	/* Root can read or write any file. */
20
	if (!(mode & X_OK))
21
		return 0;
22

23
	/* Root can execute any file that has any one of the execute
24
	 * bits set.
25
	 */
26
	if (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))
27
		return 0;
28

29
	errno = EACCES;
30
	return -1;
31
}
32

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.