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

Subversion リポジトリの参照

Diff of /branches/ccs-tools/ccstools/kernel_test/ccs_new_file_test.c

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

revision 1066 by kumaneko, Fri Mar 28 15:38:24 2008 UTC revision 1067 by kumaneko, Sat Mar 29 03:47:21 2008 UTC
# Line 12  Line 12 
12    
13  static int profile_fd = EOF;  static int profile_fd = EOF;
14  static int domain_fd = EOF;  static int domain_fd = EOF;
15    static int exception_fd = EOF;
16  static const char *policy = "";  static const char *policy = "";
17  static char self_domain[4096] = "";  static char self_domain[4096] = "";
18    
# Line 432  static void StageFileTest(void) { Line 433  static void StageFileTest(void) {
433                  show_result(bind(fd, (struct sockaddr *) &addr, sizeof(addr)), 0);                  show_result(bind(fd, (struct sockaddr *) &addr, sizeof(addr)), 0);
434                  if (fd != EOF) close(fd);                  if (fd != EOF) close(fd);
435          }          }
436    
437            filename = "/tmp/rewrite_test";
438            create2(filename);
439            policy = "allow_read/write /tmp/rewrite_test";
440            if (write_policy()) {
441                    char *cp = "deny_rewrite /tmp/rewrite_test\n";
442                    write(exception_fd, cp, strlen(cp));
443                    policy = "allow_truncate /tmp/rewrite_test";
444                    if (write_policy()) {
445                            int fd;
446    
447                            fd = open(filename, O_RDONLY);
448                            show_result(fd, 1);
449                            if (fd != EOF) close(fd);
450                            
451                            fd = open(filename, O_WRONLY | O_APPEND);
452                            show_result(fd, 1);
453                            if (fd != EOF) close(fd);
454                            
455                            fd = open(filename, O_WRONLY);
456                            show_result(fd, 0);
457                            if (fd != EOF) close(fd);
458                            
459                            fd = open(filename, O_WRONLY | O_TRUNC);
460                            show_result(fd, 0);
461                            if (fd != EOF) close(fd);
462                            
463                            fd = open(filename, O_WRONLY | O_TRUNC | O_APPEND);
464                            show_result(fd, 0);
465                            if (fd != EOF) close(fd);
466                            
467                            show_result(truncate(filename, 0), 0);
468                            
469                            cp = "255-MAC_FOR_FILE=disabled\n";
470                            write(profile_fd, cp, strlen(cp));
471                            fd = open(filename, O_WRONLY | O_APPEND);
472                            cp = "255-MAC_FOR_FILE=enforcing\n";
473                            write(profile_fd, cp, strlen(cp));
474                            show_result(ftruncate(fd, 0), 0);
475                            
476                            show_result(fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) & ~O_APPEND), 0);
477                            if (fd != EOF) close(fd);
478    
479                            delete_policy();
480                    }
481                    policy = "allow_read/write /tmp/rewrite_test";
482                    delete_policy();
483                    cp = "delete deny_rewrite /tmp/rewrite_test\n";
484                    write(exception_fd, cp, strlen(cp));
485            }
486            unlink2(filename);
487  }  }
488    
489  int main(int argc, char *argv[]) {  int main(int argc, char *argv[]) {
# Line 439  int main(int argc, char *argv[]) { Line 491  int main(int argc, char *argv[]) {
491          Init();          Init();
492          profile_fd = open(proc_policy_profile, O_WRONLY);          profile_fd = open(proc_policy_profile, O_WRONLY);
493          domain_fd = open(proc_policy_domain_policy, O_WRONLY);          domain_fd = open(proc_policy_domain_policy, O_WRONLY);
494            exception_fd = open(proc_policy_exception_policy, O_WRONLY);
495          {          {
496                  int self_fd = open(proc_policy_self_domain, O_RDONLY);                  int self_fd = open(proc_policy_self_domain, O_RDONLY);
497                  memset(self_domain, 0, sizeof(self_domain));                  memset(self_domain, 0, sizeof(self_domain));

Legend:
Removed from v.1066  
changed lines
  Added in v.1067

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