~ubuntu-branches/ubuntu/feisty/apache2/feisty

« back to all changes in this revision

Viewing changes to srclib/apr/file_io/unix/fileacc.c

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Barth
  • Date: 2006-12-09 21:05:45 UTC
  • mfrom: (0.6.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20061209210545-h70s0xaqc2v8vqr2
Tags: 2.2.3-3.2
* Non-maintainer upload.
* 043_ajp_connection_reuse: Patch from upstream Bugzilla, fixing a critical
  issue with regard to connection reuse in mod_proxy_ajp.
  Closes: #396265

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as
 
2
 * applicable.
 
3
 *
 
4
 * Licensed under the Apache License, Version 2.0 (the "License");
 
5
 * you may not use this file except in compliance with the License.
 
6
 * 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
{
 
25
    *fname = thefile->fname;
 
26
    return APR_SUCCESS;
 
27
}
 
28
 
 
29
APR_DECLARE(apr_int32_t) apr_file_flags_get(apr_file_t *f)
 
30
{
 
31
    return f->flags;
 
32
}
 
33
 
 
34
#if !defined(OS2) && !defined(WIN32)
 
35
mode_t apr_unix_perms2mode(apr_fileperms_t perms)
 
36
{
 
37
    mode_t mode = 0;
 
38
 
 
39
    if (perms & APR_USETID)
 
40
        mode |= S_ISUID;
 
41
    if (perms & APR_UREAD)
 
42
        mode |= S_IRUSR;
 
43
    if (perms & APR_UWRITE)
 
44
        mode |= S_IWUSR;
 
45
    if (perms & APR_UEXECUTE)
 
46
        mode |= S_IXUSR;
 
47
 
 
48
    if (perms & APR_GSETID)
 
49
        mode |= S_ISGID;
 
50
    if (perms & APR_GREAD)
 
51
        mode |= S_IRGRP;
 
52
    if (perms & APR_GWRITE)
 
53
        mode |= S_IWGRP;
 
54
    if (perms & APR_GEXECUTE)
 
55
        mode |= S_IXGRP;
 
56
 
 
57
#ifdef S_ISVTX
 
58
    if (perms & APR_WSTICKY)
 
59
        mode |= S_ISVTX;
 
60
#endif
 
61
    if (perms & APR_WREAD)
 
62
        mode |= S_IROTH;
 
63
    if (perms & APR_WWRITE)
 
64
        mode |= S_IWOTH;
 
65
    if (perms & APR_WEXECUTE)
 
66
        mode |= S_IXOTH;
 
67
 
 
68
    return mode;
 
69
}
 
70
 
 
71
apr_fileperms_t apr_unix_mode2perms(mode_t mode)
 
72
{
 
73
    apr_fileperms_t perms = 0;
 
74
 
 
75
    if (mode & S_ISUID)
 
76
        perms |= APR_USETID;
 
77
    if (mode & S_IRUSR)
 
78
        perms |= APR_UREAD;
 
79
    if (mode & S_IWUSR)
 
80
        perms |= APR_UWRITE;
 
81
    if (mode & S_IXUSR)
 
82
        perms |= APR_UEXECUTE;
 
83
 
 
84
    if (mode & S_ISGID)
 
85
        perms |= APR_GSETID;
 
86
    if (mode & S_IRGRP)
 
87
        perms |= APR_GREAD;
 
88
    if (mode & S_IWGRP)
 
89
        perms |= APR_GWRITE;
 
90
    if (mode & S_IXGRP)
 
91
        perms |= APR_GEXECUTE;
 
92
 
 
93
#ifdef S_ISVTX
 
94
    if (mode & S_ISVTX)
 
95
        perms |= APR_WSTICKY;
 
96
#endif
 
97
    if (mode & S_IROTH)
 
98
        perms |= APR_WREAD;
 
99
    if (mode & S_IWOTH)
 
100
        perms |= APR_WWRITE;
 
101
    if (mode & S_IXOTH)
 
102
        perms |= APR_WEXECUTE;
 
103
 
 
104
    return perms;
 
105
}
 
106
#endif
 
107
 
 
108
APR_DECLARE(apr_status_t) apr_file_data_get(void **data, const char *key,
 
109
                                           apr_file_t *file)
 
110
{    
 
111
    return apr_pool_userdata_get(data, key, file->pool);
 
112
}
 
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
{    
 
118
    return apr_pool_userdata_set(data, key, cleanup, file->pool);
 
119
}