SCCS-vsn: old/mount_lofs/mount_lofs.c 8.2
SCCS-vsn: sbin/mount_null/mount_null.c 8.2
SCCS-vsn: sbin/mount_union/mount_union.c 8.2
#include <stdlib.h>
#include <string.h>
#include <stdlib.h>
#include <string.h>
+static int subdir __P((char *, char *));
void usage __P((void));
int
void usage __P((void));
int
{
struct lofs_args args;
int ch, mntflags;
{
struct lofs_args args;
int ch, mntflags;
+ char target[MAXPATHLEN];
mntflags = 0;
while ((ch = getopt(argc, argv, "F:")) != EOF)
mntflags = 0;
while ((ch = getopt(argc, argv, "F:")) != EOF)
+ if (realpath(argv[0], target) == 0) {
+ (void)fprintf(stderr, "mount_lofs: %s: %s\n",
+ target, strerror(errno));
+ exit(1);
+ }
+
+ if (subdir(target, argv[1])) {
+ (void)fprintf(stderr,
+ "mount_lofs: %s (%s) is a sub directory of %s\n",
+ argv[0], target, argv[1]);
+ exit(1);
+ }
+
+ args.target = target;
if (mount(MOUNT_LOFS, argv[1], mntflags, &args)) {
(void)fprintf(stderr, "mount_lofs: %s\n", strerror(errno));
if (mount(MOUNT_LOFS, argv[1], mntflags, &args)) {
(void)fprintf(stderr, "mount_lofs: %s\n", strerror(errno));
+static int
+subdir(p, dir)
+ char *p;
+ char *dir;
+{
+ int l;
+
+ l = strlen(dir);
+ if (l <= 1)
+ return (1);
+
+ if ((strncmp(p, dir, l) == 0) && (p[l] == '/'))
+ return (1);
+
+ return (0);
+}
+
#include <stdlib.h>
#include <string.h>
#include <stdlib.h>
#include <string.h>
+static int subdir __P((char *, char *));
void usage __P((void));
int
void usage __P((void));
int
{
struct null_args args;
int ch, mntflags;
{
struct null_args args;
int ch, mntflags;
+ char target[MAXPATHLEN];
mntflags = 0;
while ((ch = getopt(argc, argv, "F:")) != EOF)
mntflags = 0;
while ((ch = getopt(argc, argv, "F:")) != EOF)
+ if (realpath(argv[0], target) == 0) {
+ (void)fprintf(stderr, "mount_lofs: %s: %s\n",
+ target, strerror(errno));
+ exit(1);
+ }
+
+ if (subdir(target, argv[1])) {
+ (void)fprintf(stderr,
+ "mount_null: %s (%s) is a sub directory of %s\n",
+ argv[0], target, argv[1]);
+ exit(1);
+ }
+
+ args.target = target;
if (mount(MOUNT_NULL, argv[1], mntflags, &args)) {
(void)fprintf(stderr, "mount_null: %s\n", strerror(errno));
if (mount(MOUNT_NULL, argv[1], mntflags, &args)) {
(void)fprintf(stderr, "mount_null: %s\n", strerror(errno));
+static int
+subdir(p, dir)
+ char *p;
+ char *dir;
+{
+ int l;
+
+ l = strlen(dir);
+ if (l <= 1)
+ return (1);
+
+ if ((strncmp(p, dir, l) == 0) && (p[l] == '/'))
+ return (1);
+
+ return (0);
+}
+
*
* %sccs.include.redist.c%
*
*
* %sccs.include.redist.c%
*
- * @(#)mount_union.c 8.1 (Berkeley) %G%
+ * @(#)mount_union.c 8.2 (Berkeley) %G%
*/
#include <sys/param.h>
*/
#include <sys/param.h>
#include <stdlib.h>
#include <string.h>
#include <stdlib.h>
#include <string.h>
+static int subdir __P((char *, char *));
void usage __P((void));
int
void usage __P((void));
int
{
struct union_args args;
int ch, mntflags;
{
struct union_args args;
int ch, mntflags;
+ char target[MAXPATHLEN];
int error = 0;
mntflags = 0;
int error = 0;
mntflags = 0;
+ if (realpath(argv[0], target) == 0) {
+ (void)fprintf(stderr, "mount_union: %s: %s\n",
+ target, strerror(errno));
+ exit(1);
+ }
+
+ if (subdir(target, argv[1])) {
+ (void)fprintf(stderr,
+ "mount_union: %s is a sub-directory of %s\n",
+ argv[0], argv[1]);
+ exit(1);
+ }
+
+ args.target = target;
if (mount(MOUNT_UNION, argv[1], mntflags, &args)) {
(void)fprintf(stderr, "mount_union: %s\n", strerror(errno));
if (mount(MOUNT_UNION, argv[1], mntflags, &args)) {
(void)fprintf(stderr, "mount_union: %s\n", strerror(errno));
+static int
+subdir(p, dir)
+ char *p;
+ char *dir;
+{
+ int l;
+
+ l = strlen(dir);
+ if (l <= 1)
+ return (1);
+
+ if ((strncmp(p, dir, l) == 0) && (p[l] == '/'))
+ return (1);
+
+ return (0);
+}
+