/src/httpd/srclib/apr/file_io/unix/fileacc.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* Licensed to the Apache Software Foundation (ASF) under one or more |
2 | | * contributor license agreements. See the NOTICE file distributed with |
3 | | * this work for additional information regarding copyright ownership. |
4 | | * The ASF licenses this file to You under the Apache License, Version 2.0 |
5 | | * (the "License"); you may not use this file except in compliance with |
6 | | * the License. You may obtain a copy of the License at |
7 | | * |
8 | | * http://www.apache.org/licenses/LICENSE-2.0 |
9 | | * |
10 | | * Unless required by applicable law or agreed to in writing, software |
11 | | * distributed under the License is distributed on an "AS IS" BASIS, |
12 | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | | * See the License for the specific language governing permissions and |
14 | | * limitations under the License. |
15 | | */ |
16 | | |
17 | | #include "apr_strings.h" |
18 | | #include "apr_arch_file_io.h" |
19 | | |
20 | | /* A file to put ALL of the accessor functions for apr_file_t types. */ |
21 | | |
22 | | APR_DECLARE(apr_status_t) apr_file_name_get(const char **fname, |
23 | | apr_file_t *thefile) |
24 | 317 | { |
25 | 317 | *fname = thefile->fname; |
26 | 317 | return APR_SUCCESS; |
27 | 317 | } |
28 | | |
29 | | APR_DECLARE(apr_int32_t) apr_file_flags_get(apr_file_t *f) |
30 | 0 | { |
31 | 0 | return f->flags; |
32 | 0 | } |
33 | | |
34 | | #if !defined(OS2) && !defined(WIN32) |
35 | | mode_t apr_unix_perms2mode(apr_fileperms_t perms) |
36 | 0 | { |
37 | 0 | mode_t mode = 0; |
38 | |
|
39 | 0 | if (perms & APR_FPROT_USETID) |
40 | 0 | mode |= S_ISUID; |
41 | 0 | if (perms & APR_FPROT_UREAD) |
42 | 0 | mode |= S_IRUSR; |
43 | 0 | if (perms & APR_FPROT_UWRITE) |
44 | 0 | mode |= S_IWUSR; |
45 | 0 | if (perms & APR_FPROT_UEXECUTE) |
46 | 0 | mode |= S_IXUSR; |
47 | |
|
48 | 0 | if (perms & APR_FPROT_GSETID) |
49 | 0 | mode |= S_ISGID; |
50 | 0 | if (perms & APR_FPROT_GREAD) |
51 | 0 | mode |= S_IRGRP; |
52 | 0 | if (perms & APR_FPROT_GWRITE) |
53 | 0 | mode |= S_IWGRP; |
54 | 0 | if (perms & APR_FPROT_GEXECUTE) |
55 | 0 | mode |= S_IXGRP; |
56 | |
|
57 | 0 | #ifdef S_ISVTX |
58 | 0 | if (perms & APR_FPROT_WSTICKY) |
59 | 0 | mode |= S_ISVTX; |
60 | 0 | #endif |
61 | 0 | if (perms & APR_FPROT_WREAD) |
62 | 0 | mode |= S_IROTH; |
63 | 0 | if (perms & APR_FPROT_WWRITE) |
64 | 0 | mode |= S_IWOTH; |
65 | 0 | if (perms & APR_FPROT_WEXECUTE) |
66 | 0 | mode |= S_IXOTH; |
67 | |
|
68 | 0 | return mode; |
69 | 0 | } |
70 | | |
71 | | apr_fileperms_t apr_unix_mode2perms(mode_t mode) |
72 | 1.26k | { |
73 | 1.26k | apr_fileperms_t perms = 0; |
74 | | |
75 | 1.26k | if (mode & S_ISUID) |
76 | 0 | perms |= APR_FPROT_USETID; |
77 | 1.26k | if (mode & S_IRUSR) |
78 | 1.26k | perms |= APR_FPROT_UREAD; |
79 | 1.26k | if (mode & S_IWUSR) |
80 | 1.26k | perms |= APR_FPROT_UWRITE; |
81 | 1.26k | if (mode & S_IXUSR) |
82 | 0 | perms |= APR_FPROT_UEXECUTE; |
83 | | |
84 | 1.26k | if (mode & S_ISGID) |
85 | 0 | perms |= APR_FPROT_GSETID; |
86 | 1.26k | if (mode & S_IRGRP) |
87 | 1.26k | perms |= APR_FPROT_GREAD; |
88 | 1.26k | if (mode & S_IWGRP) |
89 | 0 | perms |= APR_FPROT_GWRITE; |
90 | 1.26k | if (mode & S_IXGRP) |
91 | 0 | perms |= APR_FPROT_GEXECUTE; |
92 | | |
93 | 1.26k | #ifdef S_ISVTX |
94 | 1.26k | if (mode & S_ISVTX) |
95 | 0 | perms |= APR_FPROT_WSTICKY; |
96 | 1.26k | #endif |
97 | 1.26k | if (mode & S_IROTH) |
98 | 1.26k | perms |= APR_FPROT_WREAD; |
99 | 1.26k | if (mode & S_IWOTH) |
100 | 0 | perms |= APR_FPROT_WWRITE; |
101 | 1.26k | if (mode & S_IXOTH) |
102 | 0 | perms |= APR_FPROT_WEXECUTE; |
103 | | |
104 | 1.26k | return perms; |
105 | 1.26k | } |
106 | | #endif |
107 | | |
108 | | APR_DECLARE(apr_status_t) apr_file_data_get(void **data, const char *key, |
109 | | apr_file_t *file) |
110 | 0 | { |
111 | 0 | return apr_pool_userdata_get(data, key, file->pool); |
112 | 0 | } |
113 | | |
114 | | APR_DECLARE(apr_status_t) apr_file_data_set(apr_file_t *file, void *data, |
115 | | const char *key, |
116 | | apr_status_t (*cleanup)(void *)) |
117 | 0 | { |
118 | 0 | return apr_pool_userdata_set(data, key, cleanup, file->pool); |
119 | 0 | } |