オープンソース・ソフトウェアの開発とダウンロード

Subversion リポジトリの参照

Diff of /trunk/2.4.x/tomoyo-tools/kernel_test/tomoyo_new_file_test.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1726 by kumaneko, Mon Oct 20 14:21:31 2008 UTC revision 1996 by kumaneko, Mon Dec 22 06:08:22 2008 UTC
# Line 5  Line 5 
5   *   *
6   * Copyright (C) 2005-2008  NTT DATA CORPORATION   * Copyright (C) 2005-2008  NTT DATA CORPORATION
7   *   *
8   * Version: 1.6.5-pre   2008/10/20   * Version: 1.6.6-pre   2008/12/22
9   *   *
10   */   */
11  #include "include.h"  #include "include.h"
# Line 125  static void rmdir2(const char *pathname) Line 125  static void rmdir2(const char *pathname)
125          errno = 0;          errno = 0;
126  }  }
127    
128  static void StageFileTest(void)  static void stage_file_test(void)
129  {  {
130          char *filename = "";          char *filename = "";
131          policy = "allow_read /proc/sys/net/ipv4/ip_local_port_range "          policy = "allow_read /proc/sys/net/ipv4/ip_local_port_range "
# Line 207  static void StageFileTest(void) Line 207  static void StageFileTest(void)
207                  show_result(err ? EOF : 0, 0);                  show_result(err ? EOF : 0, 0);
208          }          }
209    
210            policy = "allow_read /dev/null if path1.type=char path1.dev_major=1 "
211                    "path1.dev_minor=3";
212            if (write_policy()) {
213                    int fd = open("/dev/null", O_RDONLY);
214                    show_result(fd, 1);
215                    if (fd != EOF)
216                            close(fd);
217                    delete_policy();
218                    fd = open("/dev/null", O_RDONLY);
219                    show_result(fd, 0);
220                    if (fd != EOF)
221                            close(fd);
222            }
223    
224            policy = "allow_read /dev/null if path1.perm=0666";
225            if (write_policy()) {
226                    int fd = open("/dev/null", O_RDONLY);
227                    show_result(fd, 1);
228                    if (fd != EOF)
229                            close(fd);
230                    delete_policy();
231                    fd = open("/dev/null", O_RDONLY);
232                    show_result(fd, 0);
233                    if (fd != EOF)
234                            close(fd);
235            }
236    
237            policy = "allow_read /dev/null if path1.perm!=0777";
238            if (write_policy()) {
239                    int fd = open("/dev/null", O_RDONLY);
240                    show_result(fd, 1);
241                    if (fd != EOF)
242                            close(fd);
243                    delete_policy();
244                    fd = open("/dev/null", O_RDONLY);
245                    show_result(fd, 0);
246                    if (fd != EOF)
247                            close(fd);
248            }
249    
250            policy = "allow_read /dev/null if path1.perm=owner_read "
251                    "path1.perm=owner_write path1.perm!=owner_execute "
252                    "path1.perm=group_read path1.perm=group_write "
253                    "path1.perm!=group_execute path1.perm=others_read "
254                    "path1.perm=others_write path1.perm!=others_execute "
255                    "path1.perm!=setuid path1.perm!=setgid path1.perm!=sticky";
256            if (write_policy()) {
257                    int fd = open("/dev/null", O_RDONLY);
258                    show_result(fd, 1);
259                    if (fd != EOF)
260                            close(fd);
261                    delete_policy();
262                    fd = open("/dev/null", O_RDONLY);
263                    show_result(fd, 0);
264                    if (fd != EOF)
265                            close(fd);
266            }
267    
268            policy = "allow_mkfifo /tmp/mknod_fifo_test "
269                    "if path1.parent.perm=01777 path1.parent.perm=sticky "
270                    "path1.parent.uid=0 path1.parent.gid=0";
271            if (write_policy()) {
272                    filename = "/tmp/mknod_fifo_test";
273                    show_result(mknod(filename, S_IFIFO, 0), 1);
274                    delete_policy();
275                    unlink2(filename);
276                    show_result(mknod(filename, S_IFIFO, 0), 0);
277            }
278    
279            {
280                    char buffer[1024];
281                    struct stat sbuf;
282                    memset(buffer, 0, sizeof(buffer));
283                    memset(&sbuf, 0, sizeof(sbuf));
284                    filename = "/dev/null";
285                    stat(filename, &sbuf);
286                    snprintf(buffer, sizeof(buffer) - 1,
287                             "allow_write %s if path1.major=%u path1.minor=%u",
288                             filename, (unsigned int) MAJOR(sbuf.st_dev),
289                             (unsigned int) MINOR(sbuf.st_dev));
290                    policy = buffer;
291                    if (write_policy()) {
292                            int fd = open(filename, O_WRONLY);
293                            show_result(fd, 1);
294                            if (fd != EOF)
295                                    close(fd);
296                            delete_policy();
297                            fd = open(filename, O_WRONLY);
298                            show_result(fd, 0);
299                            if (fd != EOF)
300                                    close(fd);
301                    }
302            }
303    
304            policy = "allow_read /dev/initctl if path1.type=fifo";
305            if (write_policy()) {
306                    int fd = open("/dev/initctl", O_RDONLY);
307                    show_result(fd, 1);
308                    if (fd != EOF)
309                            close(fd);
310                    delete_policy();
311                    fd = open("/dev/initctl", O_RDONLY);
312                    show_result(fd, 0);
313                    if (fd != EOF)
314                            close(fd);
315            }
316    
317          policy = "allow_read /dev/null if path1.parent.ino=path1.parent.ino";          policy = "allow_read /dev/null if path1.parent.ino=path1.parent.ino";
318          if (write_policy()) {          if (write_policy()) {
319                  int fd = open("/dev/null", O_RDONLY);                  int fd = open("/dev/null", O_RDONLY);
# Line 548  static void StageFileTest(void) Line 655  static void StageFileTest(void)
655  int main(int argc, char *argv[])  int main(int argc, char *argv[])
656  {  {
657          char *cp;          char *cp;
658          Init();          ccs_test_init();
659          domain_fd = open(proc_policy_domain_policy, O_WRONLY);          domain_fd = open(proc_policy_domain_policy, O_WRONLY);
660          exception_fd = open(proc_policy_exception_policy, O_WRONLY);          exception_fd = open(proc_policy_exception_policy, O_WRONLY);
661          {          {
# Line 566  int main(int argc, char *argv[]) Line 673  int main(int argc, char *argv[])
673          }          }
674          cp = "255-MAX_REJECT_LOG=1024\n";          cp = "255-MAX_REJECT_LOG=1024\n";
675          write(profile_fd, cp, strlen(cp));          write(profile_fd, cp, strlen(cp));
676          StageFileTest();          stage_file_test();
677          cp = "use_profile 0\n";          cp = "use_profile 0\n";
678          write(domain_fd, cp, strlen(cp));          write(domain_fd, cp, strlen(cp));
679          ClearStatus();          clear_status();
680          return 0;          return 0;
681  }  }

Legend:
Removed from v.1726  
changed lines
  Added in v.1996

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26