void TestStrHelp_Run_IMP(TestStringHelper *self, TestBatchRunner *runner) { TestBatchRunner_Plan(runner, (TestBatch*)self, 14); test_overlap(runner); test_to_base36(runner); test_back_utf8_char(runner); }
void TestStrHelp_Run_IMP(TestStringHelper *self, TestBatchRunner *runner) { TestBatchRunner_Plan(runner, (TestBatch*)self, 40); test_overlap(runner); test_to_base36(runner); test_utf8_round_trip(runner); test_utf8_valid(runner); test_is_whitespace(runner); test_back_utf8_char(runner); }
// if a file is a .img file, test it for overlap, otherwise do nothing static void process_file(const char *file, int level, char *overlapping_dems[], int *next_dem_number, meta_parameters *meta, int *n_dems_total) { char *base = get_filename(file); char *ext = findExt(base); if (ext && strcmp_case(ext, ".img") == 0) { char *does; ++(*n_dems_total); char *meta_filename = appendExt(file, ".meta"); meta_parameters *meta_dem = meta_read(meta_filename); if (meta_dem->general->image_data_type != DEM) { does = "Not a DEM"; } else if (test_overlap(meta, meta_dem)) { // overlaps! overlapping_dems[*next_dem_number] = STRDUP(file); ++(*next_dem_number); does = "Overlaps"; } else { does = "No"; } free(meta_filename); meta_free(meta_dem); asfPrintStatus(" %s%s - %s\n", spaces(level), base, does); } else if (ext && (strcmp_case(ext, ".meta") == 0 || strcmp_case(ext, ".ddr") == 0)) { // silently ignore the .meta, etc files -- they will be picked up // when processing the corresponding .img file ; } else { // loudly ignore other stuff in the directory asfPrintStatus(" %s%s (ignored)\n", spaces(level), base); } FREE(base); }
/* * returns: * 0: success, the caller will add it * plus: success, it is already unified, the caller should ignore it * minus: error */ static int test_add(struct super_block *sb, struct au_opt_add *add, int remount) { int err; aufs_bindex_t bend, bindex; struct dentry *root; struct inode *inode, *h_inode; root = sb->s_root; bend = au_sbend(sb); if (unlikely(bend >= 0 && au_find_dbindex(root, add->path.dentry) >= 0)) { err = 1; if (!remount) { err = -EINVAL; pr_err("%s duplicated\n", add->pathname); } goto out; } err = -ENOSPC; /* -E2BIG; */ if (unlikely(AUFS_BRANCH_MAX <= add->bindex || AUFS_BRANCH_MAX - 1 <= bend)) { pr_err("number of branches exceeded %s\n", add->pathname); goto out; } err = -EDOM; if (unlikely(add->bindex < 0 || bend + 1 < add->bindex)) { pr_err("bad index %d\n", add->bindex); goto out; } inode = add->path.dentry->d_inode; err = -ENOENT; if (unlikely(!inode->i_nlink)) { pr_err("no existence %s\n", add->pathname); goto out; } err = -EINVAL; if (unlikely(inode->i_sb == sb)) { pr_err("%s must be outside\n", add->pathname); goto out; } if (unlikely(au_test_fs_unsuppoted(inode->i_sb))) { pr_err("unsupported filesystem, %s (%s)\n", add->pathname, au_sbtype(inode->i_sb)); goto out; } err = test_br(add->path.dentry->d_inode, add->perm, add->pathname); if (unlikely(err)) goto out; if (bend < 0) return 0; /* success */ err = -EINVAL; for (bindex = 0; bindex <= bend; bindex++) if (unlikely(test_overlap(sb, add->path.dentry, au_h_dptr(root, bindex)))) { pr_err("%s is overlapped\n", add->pathname); goto out; } err = 0; if (au_opt_test(au_mntflags(sb), WARN_PERM)) { h_inode = au_h_dptr(root, 0)->d_inode; if ((h_inode->i_mode & S_IALLUGO) != (inode->i_mode & S_IALLUGO) || h_inode->i_uid != inode->i_uid || h_inode->i_gid != inode->i_gid) pr_warning("uid/gid/perm %s %u/%u/0%o, %u/%u/0%o\n", add->pathname, inode->i_uid, inode->i_gid, (inode->i_mode & S_IALLUGO), h_inode->i_uid, h_inode->i_gid, (h_inode->i_mode & S_IALLUGO)); } out: return err; }
/* * Test for mixing access to old-style and Unix98 PTYs. Since the PTY service * internally shares the set of pseudo terminals between the two types, it has * to implement checks to prevent that a PTY opened as one type is also * accessed through the other type. We test some of those checks here. */ static void test77h(void) { char *tname, ptest[PATH_MAX], ttest[PATH_MAX]; struct sigaction act, oact; size_t len; int i, n, masterfd, slavefd; subtest = 8; /* We do not want to get SIGHUP signals in this test. */ memset(&act, 0, sizeof(act)); act.sa_handler = SIG_IGN; if (sigaction(SIGHUP, &act, &oact) < 0) e(0); /* * Check that Unix98 PTYs cannot be accessed through old-style device * nodes. We check different combinations of open master and * slave ends for the Unix98 side (with 'i'): 0) opening and closing * the master only, 1) closing a slave before the master, and 2) * closing the slave after the master. * * This test relies on the implementation aspect that /dev/ttypN and * /dev/pts/N (with N in the range 0..9) map to the same PTY. It also * relies on lack of concurrent PTY allocation outside the test. */ for (i = 0; i <= 2; i++) { /* Open a Unix98 PTY and get the slave name. */ masterfd = get_unix98_pty(&tname); /* Figure out the slave index number. */ len = strlen(_PATH_DEV_PTS); if (strncmp(tname, _PATH_DEV_PTS, strlen(_PATH_DEV_PTS))) e(0); n = atoi(&tname[len]); if (n < 0 || n > 9) e(0); /* Use this index number to create old-style device names. */ snprintf(ptest, sizeof(ptest), _PATH_DEV "ptyp%u", n); snprintf(ttest, sizeof(ttest), _PATH_DEV "ttyp%u", n); /* * Now make sure that opening the old-style master and slave * fails as long as either side of the Unix98 PTY is open. */ if (open(ptest, O_RDWR | O_NOCTTY) >= 0) e(0); if (errno != EACCES && errno != EIO) e(0); if (open(ttest, O_RDWR | O_NOCTTY) >= 0) e(0); if (errno != EACCES && errno != EIO) e(0); if (i > 0) { if ((slavefd = open(tname, O_RDWR | O_NOCTTY)) < 0) e(0); if (open(ptest, O_RDWR | O_NOCTTY) >= 0) e(0); if (errno != EACCES && errno != EIO) e(0); if (open(ttest, O_RDWR | O_NOCTTY) >= 0) e(0); if (errno != EACCES && errno != EIO) e(0); if (close(slavefd) < 0) e(0); if (i > 1) { if (open(ptest, O_RDWR | O_NOCTTY) >= 0) e(0); if (errno != EACCES && errno != EIO) e(0); if (open(ttest, O_RDWR | O_NOCTTY) >= 0) e(0); if (errno != EACCES && errno != EIO) e(0); if ((slavefd = open(tname, O_RDWR | O_NOCTTY)) < 0) e(0); if (open(ptest, O_RDWR | O_NOCTTY) >= 0) e(0); if (errno != EACCES && errno != EIO) e(0); if (open(ttest, O_RDWR | O_NOCTTY) >= 0) e(0); if (errno != EACCES && errno != EIO) e(0); if (close(masterfd) < 0) e(0); masterfd = slavefd; /* ugly but saving code */ } if (open(ptest, O_RDWR | O_NOCTTY) >= 0) e(0); if (errno != EACCES && errno != EIO) e(0); if (open(ttest, O_RDWR | O_NOCTTY) >= 0) e(0); if (errno != EACCES && errno != EIO) e(0); } if (close(masterfd) < 0) e(0); /* * Once both Unix98 sides are closed, the pseudo terminal can * be reused. Thus, opening the old-style master should now * succeed. However, it is possible that we do not have * permission to open the master at all. */ if ((masterfd = open(ptest, O_RDWR | O_NOCTTY)) < 0 && errno != EACCES) e(0); if (masterfd >= 0 && close(masterfd) < 0) e(0); } /* * The reverse test, which would check that old-style PTYs cannot be * accessed through Unix98 device nodes, is impossible to perform * properly without root privileges, as we would have to create device * nodes manually with mknod(2). All we can do here is ensure that if * an old-style PTY is opened, it will not also be allocated as a * Unix98 PTY. We do a rather basic check, but only if we can open an * old-style master at all. We check two closing orders (with 'i'): * 0) the slave first, 1) the master first. Here, we make the hard * assumption that the system supports at least four pseudo terminals, * of which at least one is currently free. */ for (i = 0; i <= 1; i++) { for (n = 0; n < MIN_PTYS; n++) { snprintf(ptest, sizeof(ptest), _PATH_DEV "ptyp%u", n); if ((masterfd = open(ptest, O_RDWR | O_NOCTTY)) >= 0) break; } if (n >= MIN_PTYS) break; test_overlap(n); snprintf(ttest, sizeof(ttest), _PATH_DEV "ttyp%u", n); /* We can do part of the test only if we can open the slave. */ if ((slavefd = open(ttest, O_RDWR | O_NOCTTY)) >= 0) { test_overlap(n); if (i > 0) { if (close(masterfd) < 0) e(0); masterfd = slavefd; /* again, ugly */ } else if (close(slavefd) < 0) e(0); test_overlap(n); } if (close(masterfd) < 0) e(0); } if (sigaction(SIGHUP, &oact, NULL) < 0) e(0); }