home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / unix / ultrix / 6872 < prev    next >
Encoding:
Text File  |  1992-09-13  |  2.8 KB  |  104 lines

  1. Path: sparky!uunet!know!hri.com!noc.near.net!news.Brown.EDU!qt.cs.utexas.edu!cs.utexas.edu!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!kcgl1.eng.ohio-state.edu!DAVISM
  2. From: DAVISM@kcgl1.eng.ohio-state.edu (Michael T. Davis)
  3. Newsgroups: comp.unix.ultrix
  4. Subject: Problem w/ mount (2) on 4.2a
  5. Message-ID: <1992Sep13.171916.2353@magnus.acs.ohio-state.edu>
  6. Date: 13 Sep 92 17:19:16 GMT
  7. Sender: news@magnus.acs.ohio-state.edu
  8. Organization: The Ohio State University
  9. Lines: 92
  10. Nntp-Posting-Host: kcgl1.eng.ohio-state.edu
  11.  
  12.  
  13.     I help to maintain a system running Ultrix 4.2a -- a DECstation
  14. 5000/240.  We would like to provide normal users a method of mounting an NFS
  15. filesystem.  I thought we could just throw together a short C program which
  16. called mount(2) and install it SUID, but it doesn't seem to be working; it
  17. returns EFAULT, which doesn't make much sense to me.  (Admittedly, I'm much
  18. more comfortable under VMS, so that could explain a lot. ;-)  The man page
  19. indicates an EFAULT means that "special or name points outside the process's
  20. allocated address space."  The code follows, with hard-coded file specifica-
  21. tions replaced with upper-case representations of "generic" names.  Please
  22. send replies via E-mail.
  23.  
  24. ---8<---clip here--->8---
  25. #include <stdio.h>
  26. #include <sys/types.h>
  27. #include <sys/stat.h>
  28. #include <sys/fs_types.h>
  29.  
  30. main ( argc, argv )
  31.     int argc;
  32.     char * argv [];
  33. {
  34. char * default = "DEFAULT-LOCAL-DIR",
  35.      message [256],
  36.      * name,
  37.      * options = "ro",
  38.      * special;
  39. int rwflag = 1,
  40.     status,
  41.     type = GT_NFS;
  42.  
  43. /*
  44.  *  Check argument count
  45.  */
  46. if ( argc < 2 || argc > 3 )
  47. {
  48.     fprintf ( stderr, "%s: remote [local]\n", argv [0] );
  49.     exit ( 1 );
  50. }
  51. /*
  52.  *  Set up remote address
  53.  */
  54. special = ( char * ) argv [1];
  55. /*
  56.  *  Set up local address
  57.  */
  58. if ( argc == 3 )
  59.     name = ( char * ) argv [2];
  60. else
  61.     name = ( char * ) default;
  62.  
  63. #ifdef DEBUG
  64. printf ( "%s - attempting to mount %s on %s\n", argv [0], special, name );
  65. #endif
  66.  
  67. status = mount ( special, name, rwflag, type, options ); /* EFAULT here */
  68. if ( status < 0 )
  69. {
  70.     sprintf ( message, "%s - error mounting file system", argv [0] );
  71.     perror ( message );
  72.     exit ( 1 );
  73. }
  74. else
  75. {
  76.     char testfile [256];
  77.     struct stat file_status;
  78.  
  79.     sprintf ( testfile, "%s/TEST-FILE", name );
  80. #ifdef DEBUG
  81.     printf ( "%s - checking for test file %s\n", argv [0], testfile );
  82. #endif
  83.     status = stat ( testfile, & file_status );
  84.     if ( status < 0 )
  85.     {
  86.         sprintf ( message, "%s - error accessing test file", argv [0] );
  87.         perror ( message );
  88.         umount ( name );
  89.         exit ( 1 );
  90.     }
  91. }
  92.  
  93. exit ( 0 );
  94.  
  95. }
  96. ---8<---clip here--->8---
  97.  
  98.                             Thanks,
  99.                              Mike
  100. --
  101.  Internet: davism@KCGL1.eng.ohio-state.edu |
  102.             -or- DAVISM+@osu.edu           |   These Thoughts, They Be Mine
  103.    BITNET: DAVISM+@OHSTMAIL.BITNET         |
  104.