~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to bin/trampoline/trampoline.c

  • Committer: William Grant
  • Date: 2009-07-04 12:07:19 UTC
  • mto: (1294.4.2 ui-the-third)
  • mto: This revision was merged to the branch mainline in revision 1353.
  • Revision ID: grantw@unimelb.edu.au-20090704120719-t2kw3f4axb0hqcyr
Port the console and service to object traversal.

Show diffs side-by-side

added added

removed removed

Lines of Context:
137
137
    return ptr;
138
138
}
139
139
 
140
 
int checked_mount(const char *source, const char *target,
141
 
                  const char *filesystemtype, unsigned long mountflags,
142
 
                  const void *data)
143
 
{
144
 
    int result = mount(source, target, filesystemtype, mountflags, data);
145
 
    if (result)
146
 
    {
147
 
        syslog(LOG_ERR, "could not mount %s on %s\n", source, target);
148
 
        perror("could not mount");
149
 
        exit(1);
150
 
    }
151
 
 
152
 
    return result;
153
 
}
154
 
 
155
 
 
156
140
/* Find the path of the user components of a jail, given a mountpoint. */
157
141
char *jail_src(const char *jail_src_base, const char *jail_base,
158
142
               const char *jailpath)
163
147
 
164
148
    srclen = strlen(jail_src_base);
165
149
    dstlen = strlen(jail_base);
166
 
 
 
150
    
167
151
    src = die_if_null(malloc(strlen(jailpath) + (srclen - dstlen) + 1));
168
152
    strcpy(src, jail_src_base);
169
153
    strcat(src, jailpath+dstlen);
179
163
{
180
164
    char *jailsrc;
181
165
    char *jaillib;
182
 
    char *source_bits;
183
 
    char *target_bits;
 
166
    char *mountdata;
184
167
 
185
168
    /* Check if there is something useful in the jail. If not, it's probably
186
169
     * not mounted. */
200
183
             }
201
184
             syslog(LOG_NOTICE, "created mountpoint %s\n", jailpath);
202
185
        }
203
 
 
 
186
       
204
187
        jailsrc = jail_src(jail_src_base, jail_base, jailpath);
205
 
        checked_mount(jail_system, jailpath, NULL, MS_BIND | MS_RDONLY, NULL);
206
 
 
207
 
        source_bits = die_if_null(malloc(strlen(jailsrc) + 5 + 1));
208
 
        target_bits = die_if_null(malloc(strlen(jailpath) + 5 + 1));
209
 
        sprintf(source_bits, "%s/home", jailsrc);
210
 
        sprintf(target_bits, "%s/home", jailpath);
211
 
 
212
 
        checked_mount(source_bits, target_bits, NULL, MS_BIND, NULL);
213
 
 
214
 
        sprintf(source_bits, "%s/tmp", jailsrc);
215
 
        sprintf(target_bits, "%s/tmp", jailpath);
216
 
 
217
 
        checked_mount(source_bits, target_bits, NULL, MS_BIND, NULL);
 
188
        mountdata = die_if_null(malloc(3 + strlen(jailsrc) + 4 + strlen(jail_system) + 3 + 1));
 
189
        sprintf(mountdata, "br:%s=rw:%s=ro", jailsrc, jail_system);
 
190
        if (mount("none", jailpath, "aufs", 0, mountdata))
 
191
        {
 
192
            syslog(LOG_ERR, "could not mount %s\n", jailpath);
 
193
            perror("could not mount");
 
194
            exit(1);
 
195
        } 
218
196
 
219
197
        syslog(LOG_INFO, "mounted %s\n", jailpath);
220
198
 
221
199
        free(jailsrc);
222
 
        free(source_bits);
223
 
        free(target_bits);
 
200
        free(mountdata);
224
201
    }
225
202
 
226
203
    free(jaillib);