From 6a55c9320e3b9a59cac67846e7690da44c7d299a Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Tue, 13 Jul 2010 21:22:04 +0400 Subject: [PATCH] Ticket #2279: mcserver is deprecated. Removed mcserver and mcfs support. Reasons: (1) no longer builds (2) no one is willing to support it (3) possibly contains unfixed security holes (4) makes no sense in view of the availability of FISH Signed-off-by: Andrew Borodin --- acinclude.m4 | 1 - configure.ac | 9 +- contrib/Makefile.am | 2 +- contrib/mcserv.init | 68 -- contrib/mcserv.pamd | 6 - doc/HACKING | 3 +- doc/INSTALL | 12 - doc/README | 2 +- doc/README.QNX | 5 - doc/TODO | 4 - doc/man/Makefile.am | 4 - doc/man/es/mc.1.in | 39 +- doc/man/hu/mc.1.in | 38 +- doc/man/it/mc.1.in | 38 +- doc/man/mc.1.in | 45 +- doc/man/mcserv.8.in | 68 -- doc/man/pl/mc.1.in | 40 +- doc/man/ru/mc.1.in | 51 +- doc/man/sr/Makefile.am | 4 - doc/man/sr/mc.1.in | 38 +- doc/man/sr/mcserv.8.in | 67 -- lib/vfs/mc-vfs/HACKING | 2 - lib/vfs/mc-vfs/Makefile.am | 13 +- lib/vfs/mc-vfs/mcfs.c | 1271 ------------------------------ lib/vfs/mc-vfs/mcfs.h | 62 -- lib/vfs/mc-vfs/mcfsutil.c | 241 ------ lib/vfs/mc-vfs/mcfsutil.h | 29 - lib/vfs/mc-vfs/mcserv.c | 1399 --------------------------------- lib/vfs/mc-vfs/vfs.c | 4 - m4.include/mc-mcserver.m4 | 69 -- m4.include/mc-vfs.m4 | 4 - m4.include/vfs/mc-vfs-mcfs.m4 | 17 - maint/mc-test | 18 +- maint/mc-test-example.conf | 2 +- maint/mctest | 2 +- misc/mc.ext.in | 2 +- src/cmd.c | 9 - src/cmd.h | 1 - src/cmddef.h | 1 - src/keybind.c | 3 - src/main.c | 8 - src/textconf.c | 3 - 42 files changed, 22 insertions(+), 3682 deletions(-) delete mode 100644 contrib/mcserv.init delete mode 100644 contrib/mcserv.pamd delete mode 100644 doc/man/mcserv.8.in delete mode 100644 doc/man/sr/mcserv.8.in delete mode 100644 lib/vfs/mc-vfs/mcfs.c delete mode 100644 lib/vfs/mc-vfs/mcfs.h delete mode 100644 lib/vfs/mc-vfs/mcfsutil.c delete mode 100644 lib/vfs/mc-vfs/mcfsutil.h delete mode 100644 lib/vfs/mc-vfs/mcserv.c delete mode 100644 m4.include/mc-mcserver.m4 delete mode 100644 m4.include/vfs/mc-vfs-mcfs.m4 diff --git a/acinclude.m4 b/acinclude.m4 index 6f54b9281..5edcda5eb 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -3,7 +3,6 @@ m4_include([m4.include/ax_path_lib_pcre.m4]) m4_include([m4.include/dx_doxygen.m4]) m4_include([m4.include/mc-cflags.m4]) m4_include([m4.include/mc-check-search-type.m4]) -m4_include([m4.include/mc-mcserver.m4]) m4_include([m4.include/ac-get-fs-info.m4]) m4_include([m4.include/mc-use-termcap.m4]) m4_include([m4.include/mc-with-screen.m4]) diff --git a/configure.ac b/configure.ac index 0a4598903..749948093 100644 --- a/configure.ac +++ b/configure.ac @@ -544,7 +544,6 @@ AM_CONDITIONAL(USE_EDIT, [test -n "$use_edit"]) AM_CONDITIONAL(USE_DIFF, [test -n "$use_diff"]) AM_CONDITIONAL(ENABLE_VFS_NET, [test x"$use_net_code" = xtrue]) AM_CONDITIONAL(USE_SAMBA_FS, [test -n "$use_smbfs"]) -AM_CONDITIONAL(ENABLE_MCSERVER, [test x"$enable_mcserver" = "xyes"]) AM_CONDITIONAL(CHARSET, [test -n "$have_charset"]) AM_CONDITIONAL(CONS_SAVER, [test -n "$cons_saver"]) @@ -622,13 +621,13 @@ misc/syntax/Makefile doc/Makefile doc/hints/Makefile -doc/man/mc.1 doc/man/mcedit.1 doc/man/mcview.1 doc/man/mcserv.8 doc/man/Makefile +doc/man/mc.1 doc/man/mcedit.1 doc/man/mcview.1 doc/man/Makefile doc/man/es/mc.1 doc/man/es/Makefile doc/man/hu/mc.1 doc/man/hu/Makefile doc/man/it/mc.1 doc/man/it/Makefile doc/man/pl/mc.1 doc/man/pl/Makefile doc/man/ru/mc.1 doc/man/ru/Makefile -doc/man/sr/mc.1 doc/man/sr/mcserv.8 doc/man/sr/Makefile +doc/man/sr/mc.1 doc/man/sr/Makefile doc/hlp/Makefile doc/hlp/es/Makefile @@ -644,10 +643,6 @@ po/Makefile.in AC_OUTPUT -if test x$enable_mcserver = x; then - enable_mcserver='no' -fi - echo " Configuration: diff --git a/contrib/Makefile.am b/contrib/Makefile.am index 784ce98d0..32c5708a5 100644 --- a/contrib/Makefile.am +++ b/contrib/Makefile.am @@ -2,7 +2,7 @@ SUBDIRS = dist -noinst_DATA = README.xterm mcserv.init mcserv.pamd +noinst_DATA = README.xterm SCRIPTS_IN = mc.csh.in mc.sh.in mc-wrapper.csh.in mc-wrapper.sh.in SCRIPTS_OUT = mc.csh mc.sh mc-wrapper.csh mc-wrapper.sh diff --git a/contrib/mcserv.init b/contrib/mcserv.init deleted file mode 100644 index a0ce5ee45..000000000 --- a/contrib/mcserv.init +++ /dev/null @@ -1,68 +0,0 @@ -#! /bin/sh -# -# skeleton Example file to build /etc/init.d scripts. -# -# Version: @(#) /etc/init.d/mcserv 07/10/2000 -# -# Author: Tomasz Koczko, -# Michele Marziani -# Preston Brown -# -# chkconfig: - 86 30 -# description: The Midnight Commander server allows users on remote machines \ -# to use the Midnight Commander file manager to manipulate their \ -# files on the machine running the server. The server \ -# authenticates the user through PAM, which by default requires \ -# a username/password combination before allowing access. -# processname: mcserv - -# Source function library. -. /etc/init.d/functions - -RETVAL=0 - -prog="mcserv" - -start() { - echo -n $"Starting $prog: " - daemon /usr/bin/mcserv -d - RETVAL=$? - touch /var/lock/subsys/mcserv - echo -} - -stop() { - echo -n $"Stopping $prog: " - killproc mcserv - RETVAL=$? - rm -f /var/lock/subsys/mcserv - echo -} - -# See how we were called. -case "$1" in - start) - start - ;; - status) - status mcserv - ;; - restart|reload) - stop - start - ;; - condrestart) - if [ -f /var/lock/subsys/mcserv ]; then - stop - start - fi - ;; - stop) - stop - ;; - *) - echo $"Usage: $0 {start|stop|status|restart|reload|condrestart}" - exit 1 -esac - -exit $RETVAL diff --git a/contrib/mcserv.pamd b/contrib/mcserv.pamd deleted file mode 100644 index 7bb5d0c11..000000000 --- a/contrib/mcserv.pamd +++ /dev/null @@ -1,6 +0,0 @@ -#%PAM-1.0 -auth required /lib/security/pam_listfile.so item=user sense=deny file=/etc/ftpusers onerr=succeed -auth required /lib/security/pam_stack.so service=system-auth -auth required /lib/security/pam_shells.so -account required /lib/security/pam_stack.so service=system-auth -session required /lib/security/pam_stack.so service=system-auth diff --git a/doc/HACKING b/doc/HACKING index b09e518fb..4e2932064 100644 --- a/doc/HACKING +++ b/doc/HACKING @@ -357,8 +357,7 @@ NULL: When you pass NULL as an argument of a varargs function, cast the This tip applies at least to catstrs (edit/edit.h), execl(3), execle(3), execlp(3), g_strconcat (glib), parent_call - (src/background.h), parent_call_string (src/background.h), - rpc_get (vfs/mcfsutil.h), rpc_send (vfs/mcfsutil.h). + (src/background.h), parent_call_string (src/background.h). example: char *path = g_strconcat("dir", "/", "file", (char *)0); diff --git a/doc/INSTALL b/doc/INSTALL index 70bb0e675..e2cd34bef 100644 --- a/doc/INSTALL +++ b/doc/INSTALL @@ -178,18 +178,6 @@ VFS options: libext2fs library available, this option adds support for recovering deleted files (the undel virtual file system). -`--enable-vfs-mcfs' - Enable Support MCFS (mc's network filesystem). - This option enables mcfs - a non-standard remote filesystem - designed specifically for the Midnight Commander. It also enables - a server for that filesystem, mcserv. Please note that the - implementation of mcfs is not optimized for speed. There may be - security issues with mcserv - don't run it if you don't need it. - -`--enable-mcserver' - (off by default) - Support mc-specific networking file system server - `--disable-netcode' This option disables support for networked virtual filesystems. It's primarily used by developers to make sure that the code would diff --git a/doc/README b/doc/README index cf5ea7a60..27a45a63c 100644 --- a/doc/README +++ b/doc/README @@ -133,7 +133,7 @@ These are hints for the text mode edition: * The Virtual File System is a cute addition to the project, you may browse in tar and compressed tar files as well as browsing remote - machines with the mcfs file system. + machines with the fish file system. * Please read the manual page. diff --git a/doc/README.QNX b/doc/README.QNX index b681ebca4..c4675d092 100644 --- a/doc/README.QNX +++ b/doc/README.QNX @@ -276,11 +276,6 @@ src/ vfs/ - Makefile.in: - - 'install' target: 'mcserv' not installed, if net-code not enabled - by 'configure'. - / README.QNX: diff --git a/doc/TODO b/doc/TODO index 3bea04ae3..f2c341974 100644 --- a/doc/TODO +++ b/doc/TODO @@ -310,10 +310,6 @@ ideas still waiting for their implementation. * Optimizations and cleanup - - Optimize the mcfs read and write code: make the code output 8k - blocks all the time (if we have called mc_hint_readall) and probe - the input for a possible cancel. - - When verbose is off, remove all the clutter on the screen about the files being copied. diff --git a/doc/man/Makefile.am b/doc/man/Makefile.am index 50a1a258c..5d69ce8d6 100644 --- a/doc/man/Makefile.am +++ b/doc/man/Makefile.am @@ -1,8 +1,4 @@ DIST_SUBDIRS = es hu it pl ru sr SUBDIRS = $(DOC_LINGUAS) -if ENABLE_MCSERVER -man_MANS = mc.1 mcedit.1 mcview.1 mcserv.8 -else man_MANS = mc.1 mcedit.1 mcview.1 -endif diff --git a/doc/man/es/mc.1.in b/doc/man/es/mc.1.in index f833a1407..24e54b985 100644 --- a/doc/man/es/mc.1.in +++ b/doc/man/es/mc.1.in @@ -2810,43 +2810,6 @@ Ejemplos: /#sh:pepe@sincomprimir.ssh.edu/privado .fi -.\"NODE " Network File System" -.SH " Sistema de archivos en Red" -El sistema de archivos en red de Midnight Commander es un sistema de -archivos en red básico que permite manipular archivos en una máquina -remota como si estuviesen accesibles localmente. Para ello, la máquina -remota debe estar ejecutando el programa servidor mcserv(8). -.PP -Para conectar a una máquina remota, sólo necesitamos hacer el cambio de -directorio a un directorio especial cuyo nombre tendrá la forma: -.PP -.I /#mc:[usuario@]máquina[:puerto][directorio\-remoto] -.PP -Los elementos -.IR usuario , -.I puerto -y -.I directorio\-remoto -son opcionales. Si especificamos el elemento -.I usuario -entonces Midnight Commander intentará acceder a la -máquina como ese usuario, si no, usará nuestro login. -.PP -El elemento -.I puerto -es necesario cuando el servidor remoto se ejecuta en un puerto especial -(véase la página del manual de mcserv(8) para más información acerca de -puertos); finalmente, si el elemento -.I directorio\-remoto -está presente, nuestro directorio actual en la máquina remota -será éste. -.PP -Ejemplos: -.PP -.nf - /#mc:ftp.nuclecu.unam.mx/linux/local - /#mc:pepe@foo.edu:11321/privado -.fi .\"NODE " SMB File System" .SH " Sistema de archivos SMB" El SMBfs permite manipular archivos en máquinas remotas con el protocolo @@ -3763,7 +3726,7 @@ La última versión de este programa puede encontrarse en ftp://ftp.gnu.org/gnu/mc/. .\"NODE "SEE ALSO" .SH "VÉASE TAMBIÉN" -mcedit(1), mcserv(8), sh(1), bash(1), tcsh(1), zsh(1), ed(1), view(1), +mcedit(1), sh(1), bash(1), tcsh(1), zsh(1), ed(1), view(1), terminfo(1), gpm(1). .PP .nf diff --git a/doc/man/hu/mc.1.in b/doc/man/hu/mc.1.in index 62c3e9abb..c875dee17 100644 --- a/doc/man/hu/mc.1.in +++ b/doc/man/hu/mc.1.in @@ -2711,42 +2711,6 @@ Példák: /#sh:joe@want.compression.edu:C/private /#sh:joe@noncompressed.ssh.edu/private .fi -.\"NODE " Network File System" -.SH " Hálózati fájlrendszer" -A Midnight Commander fájlrendszere hálózat alapú fájlrendszer, amely -lehetővé teszi számodra azt, hogy távoli gépeken fájlokkal úgy -dolgozhass, mintha azok a saját gépeden lennének. Ennek használatához a -távoli gépnek futtania kell az mcserv(8) szerver programot. -.PP -A távoli géphez történő kapcsolódáshoz csak egy speciális nevű -könyvtárba kell belépned, amelynek a neve a következő: -.PP -.I /#mc:[felhasználó@]machine[:port][távoli\-könyvtár] -.PP -A -.I felhasználó, port -és a -.I távoli\-könyvtár -elemek opcionálisak. Ha megadod a -.I felhasználó -elemet, akkor a Midnight Commander megpróbál a távoli gépre ilyen -felhasználói névvel belépni, egyébként pedig a belépett felhasználó -nevét használja. -.PP -A -.I port -elemet akkor használható, ha a távoli gép speciális portot használ (lásd -az mcserv(8) man oldalt a további portokkal kapcsolatos információkért); -végül, ha a -.I távoli\-könyvtár -elem meg van adva, a távoli gép megadott könyvtárára vált át. -.PP -Például: -.PP -.nf - /#mc:ftp.nuclecu.unam.mx/linux/local - /#mc:joe@foo.edu:11321/private -.fi .\"NODE " Undelete File System" .SH " Törlés visszaállítása" (csak ext2; second extended filesystem) @@ -3130,7 +3094,7 @@ sunsite.mff.cuni.cz címen a /GNU/mc könyvtárban és az ftp.teuto.de címen az /lmb/mc könyvtárban. .\"NODE "SEE ALSO" .SH "Lásd még..." -ed(1), gpm(1), mcserv(8), terminfo(1), view(1), sh(1), bash(1), tcsh(1), +ed(1), gpm(1), terminfo(1), view(1), sh(1), bash(1), tcsh(1), zsh(1). .PP .nf diff --git a/doc/man/it/mc.1.in b/doc/man/it/mc.1.in index 8dfbb68b2..3ba2b3f21 100644 --- a/doc/man/it/mc.1.in +++ b/doc/man/it/mc.1.in @@ -2721,42 +2721,6 @@ Esempi: /#sh:joe@vuole.lacompressione.edu:C/privato /#sh:joe@noncompresso.ssh.edu/privato .fi -.\"NODE " Network File System" -.SH " File system di rete" -Il file system di rete del Midnight Commander è un file system basato -sulla rete che permette di manipolare i file su di una macchina remota -come se fossero locali. Per usarlo, sulla macchina remota deve essere -in esecuzione il programma server mcserv(8). -.PP -Per connettersi ad una macchina remota, basta solo fare cd -in una speciale directory il cui nome ha il seguente formato: -.PP -.I /#mc:[utente@]macchina[:porta][dir\-remota] -.PP -Gli elementi -.I utente, porta -e -.I dir\-remota -sono opzionali. Se si specifica l'elemento -.I utente -alloral il Midnight Commander tenterà di connettersi alla macchina remota -con quell'utente, altrimenti userà il nome di login. -.PP -L'elemento -.I porta -viene usato quando la macchina remota usa una porta speciale; -(vedere la magina man mcserv(8) per ulteriori informazioni sulle porte); -infine se l'elemento -.I dir\-remota -è presente, la directory corrente sulla macchina remota sarà impostata -a questo valore. -.PP -Esempi: -.PP -.nf - /#mc:ftp.nuclecu.unam.mx/linux/locale - /#mc:joe@foo.edu:11321/privato -.fi .\"NODE " Undelete File System" .SH " Recupero file cancellati" Su sistemi Linux, se si richiede, tramite configure, di usare la @@ -3152,7 +3116,7 @@ L'ultima versione di questo programma si trova su ftp://ftp.gnu.org/gnu/mc/. .\"NODE "SEE ALSO" .SH "VEDERE ANCHE" -ed(1), gpm(1), mcserv(8), terminfo(1), view(1), sh(1), bash(1), +ed(1), gpm(1), terminfo(1), view(1), sh(1), bash(1), tcsh(1), zsh(1). .PP .nf diff --git a/doc/man/mc.1.in b/doc/man/mc.1.in index d18c02c6a..a96d8afc3 100644 --- a/doc/man/mc.1.in +++ b/doc/man/mc.1.in @@ -3073,11 +3073,8 @@ used to manipulate tar and compressed tar files; the used to recover deleted files on ext2 file systems (the default file system for Linux systems), .I fish -(for manipulating files over shell connections such as rsh and ssh) and -finally the -.I mcfs -(Midnight Commander file system), a network based file system. If the -code was compiled with +(for manipulating files over shell connections such as rsh and ssh). +If the code was compiled with .I smbfs support, you can manipulate files on remote systems with the SMB (CIFS) protocol. @@ -3205,42 +3202,6 @@ Examples: /#sh:joe@noncompressed.ssh.edu/private /#sh:joe@somehost.ssh.edu:2222/private .fi -.\"NODE " Network File System" -.SH " Network File System" -The Midnight Commander file system is a network base file system that -allows you to manipulate the files in a remote machine as if they were -local. To use this, the remote machine must be running the mcserv(8) -server program. -.PP -To connect to a remote machine, you just need to chdir into a special -directory which name is in the following format: -.PP -.I /#mc:[user@]machine[:port][remote\-dir] -.PP -The -.I user, port -and -.I remote\-dir -elements are optional. If you specify the -.I user -element then the Midnight Commander will try to logon on the remote -machine as that user, otherwise it will use your login name. -.PP -The -.I port -element is used when the remote server is running on a special port -(see the mcserv(8) manual page for more information about ports); -finally, if the -.I remote\-dir -element is present, your current directory on the remote machine will -be set to this one. -.PP -Examples: -.PP -.nf - /#mc:ftp.nuclecu.unam.mx/linux/local - /#mc:joe@foo.edu:11321/private -.fi .\"NODE " Undelete File System" .SH " Undelete File System" On Linux systems, if you asked configure to use the ext2fs undelete @@ -4151,7 +4112,7 @@ The latest version of this program can be found at ftp://ftp.gnu.org/gnu/mc/. .\"NODE "SEE ALSO" .SH "SEE ALSO" -ed(1), gpm(1), mcserv(8), terminfo(1), view(1), sh(1), bash(1), +ed(1), gpm(1), terminfo(1), view(1), sh(1), bash(1), tcsh(1), zsh(1). .PP .nf diff --git a/doc/man/mcserv.8.in b/doc/man/mcserv.8.in deleted file mode 100644 index 78823cfeb..000000000 --- a/doc/man/mcserv.8.in +++ /dev/null @@ -1,68 +0,0 @@ -.TH mcserv 8 "August 2009" "MC Version 4.7.0-pre1" "GNU Midnight Commander" -.SH NAME -mcserv \- Midnight Commander file server. -.SH USAGE -.B mcserv -[\-diqvf] [\-p portnum] -.SH DESCRIPTION -.LP -mcserv is the server program for the Midnight Commander networking -file system. It provides access to the host file system to clients -running the Midnight file system (currently, only the Midnight -Commander file manager). -.PP -If the program is run as root the program will try to get a reserved -port otherwise it will use 9876 as the port. -.PP -If the system has a portmapper running, then the port will be -registered with the portmapper and thus clients will automatically -connect to the right port. If the system does not have a portmapper, -then a port should be manually specified with the -p option (see -below). -.PP -.SH OPTIONS -.TP -.I "-d" -Become a daemon, you should use this flag if you start the program -from one of the system startup files. This flag will make the program -handle any number of incoming requests by forking a new copy of itself -for each client. -.TP -.I "-q" -Quiet mode. -.TP -.I "-p" -To make the server listen on the specified -.B portnum -port. -.TP -.I "-f" -Allow ftp authentication as a fallback if the other methods fail. -This is only useful on systems where the password checking method is not -supported by this version of mcserv. The local ftp server is contacted -with the username and password. The user is authenticated if the ftp -server accepts the credentials. Use this option with care and only -when necessary. -.TP -.I "-v" -Toggle on the verbose mode. -.SH LICENSE -This program is distributed under the terms of the GNU General Public -License as published by the Free Software Foundation. See the built-in -help for details on the License and the lack of warranty. -.SH BUGS -This program currently uses port 9876, and not a system secure port. -This is a potential security problem since it could be run by any user -on the system if the system daemon is not running. -.SH SEE ALSO -mc(1), portmap(8) -.PP -.PP -.nf -The Midnight Commander page on the World Wide Web: - http://www.midnight-commander.org/ -.fi -.PP -.SH AUTHORS -Miguel de Icaza (miguel@ximian.com). - diff --git a/doc/man/pl/mc.1.in b/doc/man/pl/mc.1.in index dcd65af58..f1a93aee6 100644 --- a/doc/man/pl/mc.1.in +++ b/doc/man/pl/mc.1.in @@ -2344,44 +2344,6 @@ Przykłady: /#sh:joe@want.compression.edu:C/private /#sh:joe@noncompressed.ssh.edu/private .fi -.\"NODE " Network File System" -.SH " Sieciowe systemy plików" -Midnight Commander pozwala na obsługę zdalnych systemów i manipulowanie -na ich dyskach, tak jakby były one lokalne. Żeby to było możliwe -druga maszyna musi być uruchomiona razem z programem -.BR mcserv (8). -.PP -Żeby podłączyć się do obcego komputera musisz przejść do katalogu w specjalny -sposób opisany poniżej: -.PP -.I mc:[użytkownik@]komputer[:port][katalog] -.PP -.IR Użytkownik , -.I port -i -.I katalog -są opcjami nieobowiązkowymi. Jeśli podasz -.I użytkownika -Midnight Commander spróbuje zalogować się do systemu zdalnego jako -zadany użytkownik, w przeciwnym wypadku spróbuje użyć twojej aktualnej -nazwy zgłoszeniowej. -.PP -.I Port -jest używany jeśli zdalny komputer jest odpalony na niestandardowych portach -(zobacz stronę manuala -.BR mcserv (8) -po więcej informacji o portach); i wreszcie -jeśli -.I katalog -jest podany, twoim katalogiem domowym na zdalnym komputerze będzie ten podany. -.PP -Przykłady: -.PP -.nf - mc:ftp.nuclecu.unam.mx/linux/local - mc:joe@foo.edu:11321/private -.fi -.PP .\"NODE " Undelete File System" .SH " Odzyskiwanie plików" Na systemach Linuksowych, jeśli dodałeś w konfiguracji opcję przywracania @@ -2831,7 +2793,7 @@ katalogu /linux/local i w Europie na serwerze sunsite.mff.cuni.cz w katalogu /GNU/mc i na serwerze ftp.teuto.de w katalogu /lmb/mc. .\"NODE "SEE ALSO" .SH ZOBACZ TAKŻE -ed(1), gpm(1), mcserv(8), terminfo(1), view(1), sh(1), bash(1), +ed(1), gpm(1), terminfo(1), view(1), sh(1), bash(1), tcsh(1), zsh(1). .PP .nf diff --git a/doc/man/ru/mc.1.in b/doc/man/ru/mc.1.in index 312486aa8..6aa45f111 100644 --- a/doc/man/ru/mc.1.in +++ b/doc/man/ru/mc.1.in @@ -1,6 +1,6 @@ .\"TOPICS "Разделы помощи:" .\" TODO: Перевести раздел EXTernal File System -.TH MC "29 Июня 2010" "MC Version 4.7.4" "GNU Midnight Commander" +.TH MC "14 Июля 2010" "MC Version 4.7.4" "GNU Midnight Commander" .\"SKIP_SECTION" .SH "НАИМЕНОВАНИЕ" mc \- Визуальная оболочка для Unix\-подобных систем. @@ -3404,10 +3404,6 @@ MC может быть собран с поддержкой файловой с .\"FIle transfer over SHell filesystem" .br .\"LINK2" -Файловая система NFS (Network File System) -.\"Network File System" -.br -.\"LINK2" Файловая система UFS (Undelete File System) .\"Undelete File System" .br @@ -3568,49 +3564,6 @@ bash\-совместимая оболочка shell. /#sh:joe@noncompressed.ssh.edu/private /#sh:joe@somehost.ssh.edu:2222/private .fi -.\"NODE " Network File System" -.SH " Файловая система NFS (Network File System)" -Файловая система mc \- это еще одна сетевая файловая система, которая -позволяет работать с файлами на удаленном компьютере. Для того, чтобы -можно было воспользоваться этой ФС, на удаленном компьютере должна быть -запущена серверная программа -.BR mcserv(8) . -.PP -Для соединения с удаленным компьютером нужно выполнить команду -перехода в каталог, имя которого строится в соответствии со следующим -форматом: -.PP -.I /#mc:[user@]machine[:port][remote\-dir] -.PP -Элементы -.IR user ", " port -и -.I remote\-dir -не обязательны. -.PP -Если задан элемент -.IR user , -то Midnight Commander будет регистрироваться на удаленный компьютер под -этим именем, в противном случае \- под тем именем, с которым вы -зарегистрированы в локальной системе. -.PP -Элемент -.I port -используется в том случае, если удаленный компьютер использует -специальный порт (чтобы узнать, что такое порт и как его использовать, -смотрите страницу руководства -.BR mcserv(8) . -Если задан элемент -.IR remote\-dir , -то указанный каталог станет текущим после соединения с удаленным -компьютером. -.PP -Примеры: -.PP -.nf - /#mc:ftp.nuclecu.unam.mx/linux/local - /#mc:joe@foo.edu:11321/private -.fi .\"NODE " Undelete File System" .SH " Файловая система UFS (Undelete File System)" В ОС Linux можно сконфигурировать файловую систему ext2fs, используемую @@ -4471,7 +4424,7 @@ Commander; используется только в тех случаях, ко ftp://ftp.gnu.org/gnu/mc/. .\"NODE "SEE ALSO" .SH "Другие источники" -ed(1), gpm(1), mcserv(8), terminfo(1), view(1), sh(1), bash(1), tcsh(1), +ed(1), gpm(1), terminfo(1), view(1), sh(1), bash(1), tcsh(1), zsh(1), mcedit(1). .PP .nf diff --git a/doc/man/sr/Makefile.am b/doc/man/sr/Makefile.am index 7ec49ceb9..e4d029c73 100644 --- a/doc/man/sr/Makefile.am +++ b/doc/man/sr/Makefile.am @@ -1,7 +1,3 @@ LANG=sr mandir = @mandir@/$(LANG) -if ENABLE_MCSERVER -man_MANS = mc.1 mcserv.8 -else man_MANS = mc.1 -endif diff --git a/doc/man/sr/mc.1.in b/doc/man/sr/mc.1.in index 519dfc8c7..5c1f1fe95 100644 --- a/doc/man/sr/mc.1.in +++ b/doc/man/sr/mc.1.in @@ -2731,42 +2731,6 @@ if the /#sh:joe@hocu.komprimovanje.edu:C/private /#sh:joe@nekomprimovan.ssh.edu/private .fi -.\"NODE " Network File System" -.SH " Мрежни систем датотека" -Систем датотека Поноћног наредника је систем датотека заснован на -мрежи који вам омогућава да радите са датотекама на удаљеној машини, -као да су оне у локалу. Да бисте ово користили, удаљена машина мора да -има покренут серверски програм mcserv(8). -.PP -Да бисте се повезали са удаљеном машином, потребно је само да -поставите текући директоријум на посебни директоријум чије име је у -следећем формату: -.PP -.I /#mc:[корисник@]машина[:порт][удаљени\-дир] -.PP -Елементи -.I корисник, порт -и -.I удаљени\-дир -су необавезни. Уколико задате елемент -.IR корисник , -Поноћни наредник ће покушати да се пријави на удаљену машину под тим -корисничким именом, а иначе ће користити ваше корисничко име. -.PP -Елемент -.I порт -се користи када је удаљени сервер покренут на посебном порту -(погледајте страницу упутства mcserv(8) за више информација о -портовима); најзад, уколико је присутан елемент -.IR удаљени\-дир , -ваш текући директоријум на удаљеној машини ће бити постављен на њега. -.PP -Примери: -.PP -.nf - /#mc:ftp.nuclecu.unam.mx/linux/local - /#mc:joe@trlababa.edu:11321/private -.fi .\"NODE " Undelete File System" .SH " Систем датотека за одбрисање" На ГНУ\-овим системима, уколико сте од програма `configure' захтевали @@ -3280,7 +3244,7 @@ MC_DATADIR. Ако ова променљива није постављена, б ftp://ftp.gnu.org/gnu/mc/. .\"NODE "SEE ALSO" .SH "ВИДИТЕ И" -ed(1), gpm(1), mcserv(8), terminfo(1), view(1), sh(1), bash(1), +ed(1), gpm(1), terminfo(1), view(1), sh(1), bash(1), tcsh(1), zsh(1). .PP .nf diff --git a/doc/man/sr/mcserv.8.in b/doc/man/sr/mcserv.8.in deleted file mode 100644 index 92ab726b9..000000000 --- a/doc/man/sr/mcserv.8.in +++ /dev/null @@ -1,67 +0,0 @@ -.TH mcserv 8 "16. 1995." -.SH -mcserv \- . -.SH ÿ -.B mcserv -[\-diqvf] [\-p ] -.SH -.LP -mcserv -. - ( - ). -.PP - , - , 9876. -.PP - , - , - . , - -p ( ). -.PP -.SH -.TP -.I "-d" - ; - -. - . -.TP -.I "-q" - . -.TP -.I "-p" - -.B portnum . -.TP -.I "-f" - FTP- - . - mcserv - . FTP- - . - FTP- . - . -.TP -.I "-v" - . -.SH Ƶư - - - . - . -.SH Ⱥ - 9876, . - , - . -.SH µ -mc(1), portmap(8) -.PP -.PP -.nf - : - http://www.midnight-commander.org/ -.fi -.PP -.SH ²Ƹ - (Miguel de Icaza) (miguel@ximian.com). - diff --git a/lib/vfs/mc-vfs/HACKING b/lib/vfs/mc-vfs/HACKING index 8e223aa22..9d616bb92 100644 --- a/lib/vfs/mc-vfs/HACKING +++ b/lib/vfs/mc-vfs/HACKING @@ -63,7 +63,6 @@ vfs ---- direntry ---- cpio } archives | |---- extfs ---- extfs archives |---- localfs ---- sfs ---- sfs archives - |---- mcfs |---- smbfs |---- undelfs @@ -81,7 +80,6 @@ ftpfs no yes yes no extfs no no yes yes localfs no no N/A N/A sfs no yes yes N/A -mcfs no yes no no smbfs no yes no no undelfs no yes no yes diff --git a/lib/vfs/mc-vfs/Makefile.am b/lib/vfs/mc-vfs/Makefile.am index 31ea8f5db..ca0d909d4 100644 --- a/lib/vfs/mc-vfs/Makefile.am +++ b/lib/vfs/mc-vfs/Makefile.am @@ -27,8 +27,6 @@ VFSHDRS = \ ftpfs.h \ gc.h \ local.h \ - mcfs.h \ - mcfsutil.h \ netutil.h \ smbfs.h \ utilvfs.h \ @@ -46,7 +44,7 @@ if ENABLE_VFS_UNDELFS UNDEL_FILES = $(UNDELFILES) endif -NETFILES = netutil.c fish.c ftpfs.c mcfs.c mcfsutil.c $(SMB_NETFILES) +NETFILES = netutil.c fish.c ftpfs.c $(SMB_NETFILES) NONETFILES = $(BASICFILES) $(UNDEL_FILES) @@ -90,15 +88,6 @@ else libvfs_mc_la_SOURCES = $(NONETFILES) endif -if ENABLE_VFS -if ENABLE_MCSERVER -sbin_PROGRAMS = mcserv -mcserv_SOURCES = mcserv.c -mcserv_LDADD = $(MCSERVLIBS) $(GLIB_LIBS) libvfs-mc.la -endif -endif - - SAMBA_DIST = \ Makefile.in \ aclocal.m4 \ diff --git a/lib/vfs/mc-vfs/mcfs.c b/lib/vfs/mc-vfs/mcfs.c deleted file mode 100644 index 70d6ace8a..000000000 --- a/lib/vfs/mc-vfs/mcfs.c +++ /dev/null @@ -1,1271 +0,0 @@ -/* Virtual File System: Midnight Commander file system. - - Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, - 2004, 2005, 2007 Free Software Foundation, Inc. - - Written by Miguel de Icaza - Andrej Borsenkow - Norbert Warmuth - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ - -/** - * \file - * \brief Source: Midnight Commander file system - * \author Miguel de Icaza - * \author Andrej Borsenkow - * \author Norbert Warmuth - * - * Namespace: exports mcfs_vfs_ops, tcp_invalidate_socket - */ - -#include - -#ifdef ENABLE_VFS_MCFS -#include -#include -#include -#include -#include -#include -#include -#include /* POSIX-required by sys/socket.h and netdb.h */ -#include /* struct hostent */ -#include /* AF_INET */ -#include /* struct in_addr */ -#ifdef HAVE_ARPA_INET_H -#include -#endif - -#ifdef HAVE_PMAP_SET -#include -#include -#ifdef HAVE_RPC_PMAP_CLNT_H -#include -#endif -#endif - -#include "lib/global.h" -#include "src/wtools.h" /* message() */ -#include "src/main.h" /* print_vfs_message */ -#include "utilvfs.h" -#include "vfs.h" -#include "vfs-impl.h" -#include "mcfs.h" -#include "mcfsutil.h" -#include "netutil.h" - -#ifndef INADDR_NONE -# define INADDR_NONE (0xffffffffU) -#endif - -#define MCFS_MAX_CONNECTIONS 32 - -static struct _mcfs_connection { - char *host; - char *user; - char *home; - int sock; - int port; - int version; -} mcfs_connections[MCFS_MAX_CONNECTIONS]; - - -#define mcserver_port 9876 - -typedef struct _mcfs_connection mcfs_connection; - -typedef struct { - int handle; - mcfs_connection *conn; -} mcfs_handle; - -static char *mcfs_gethome (mcfs_connection * mc); -static int my_errno; -static struct vfs_class vfs_mcfs_ops; - -/* Extract the hostname and username from the path */ -/* path is in the form: hostname:user/remote-dir */ -static char * -mcfs_get_host_and_username (const char *path, char **host, char **user, - int *port, char **pass) -{ - return vfs_split_url (path, host, user, port, pass, 0, 0); -} - -static void -mcfs_fill_names (struct vfs_class *me, fill_names_f func) -{ - int i; - char *name; - - (void) me; - - for (i = 0; i < MCFS_MAX_CONNECTIONS; i++) { - if (mcfs_connections[i].host == 0) - continue; - name = g_strconcat ("/#mc:", mcfs_connections[i].user, - "@", mcfs_connections[i].host, (char *) NULL); - (*func) (name); - g_free (name); - } -} - -/* This routine checks the server RPC version and logs the user in */ -static int -mcfs_login_server (int my_socket, char *user, int port, - int port_autodetected, char *netrcpass, int *version) -{ - int result; - char *pass; - - /* Send the version number */ - rpc_send (my_socket, RPC_INT, *version, RPC_END); - if (0 == rpc_get (my_socket, RPC_INT, &result, RPC_END)) - return 0; - - if (result != MC_VERSION_OK) { - message (D_ERROR, _("MCFS"), - _("The server does not support this version")); - close (my_socket); - return 0; - } - - /* FIXME: figure out why last_current_dir used to be passed here */ - rpc_send (my_socket, RPC_INT, MC_LOGIN, RPC_STRING, "/", - RPC_STRING, user, RPC_END); - - if (0 == rpc_get (my_socket, RPC_INT, &result, RPC_END)) - return 0; - - if (result == MC_NEED_PASSWORD) { - if (port > 1024 && port_autodetected) { - int v; - v = query_dialog (_("Warning"), - _ - ("The remote server is not running on a system port\n" - "you need a password to log in, but the information may\n" - "not be safe on the remote side. Continue?\n"), - D_ERROR, 2, _("&Yes"), _("&No")); - - if (v == 1) { - close (my_socket); - return 0; - } - } - if (netrcpass != NULL) - pass = g_strdup (netrcpass); - else - pass = vfs_get_password (_("MCFS Password required")); - if (!pass) { - rpc_send (my_socket, RPC_INT, MC_QUIT, RPC_END); - close (my_socket); - return 0; - } - rpc_send (my_socket, RPC_INT, MC_PASS, RPC_STRING, pass, RPC_END); - - wipe_password (pass); - - if (0 == rpc_get (my_socket, RPC_INT, &result, RPC_END)) - return 0; - - if (result != MC_LOGINOK) { - message (D_ERROR, _("MCFS"), _("Invalid password")); - rpc_send (my_socket, RPC_INT, MC_QUIT, RPC_END); - close (my_socket); - return 0; - } - } - return my_socket; -} - -static int -mcfs_get_remote_port (struct sockaddr_in *sin, int *version) -{ -#ifdef HAVE_PMAP_GETMAPS - int port; - struct pmaplist *pl; - - *version = 1; - port = mcserver_port; - for (pl = pmap_getmaps (sin); pl; pl = pl->pml_next) - if (pl->pml_map.pm_prog == RPC_PROGNUM - && pl->pml_map.pm_prot == IPPROTO_TCP - && pl->pml_map.pm_vers >= (unsigned long) *version) { - *version = (int) pl->pml_map.pm_vers; - port = pl->pml_map.pm_port; - } - return port; -#else -#ifdef HAVE_PMAP_GETPORT - int port; - for (*version = RPC_PROGVER; *version >= 1; (*version)--) - port = pmap_getport (sin, RPC_PROGNUM, *version, IPPROTO_TCP); - if (port != NULL) - return port; -#endif /* HAVE_PMAP_GETPORT */ - *version = 1; - return mcserver_port; -#endif /* HAVE_PMAP_GETMAPS */ -} - -/* This used to be in utilvfs.c, but as it deals with portmapper, it - is probably useful for mcfs */ -static int -mcfs_create_tcp_link (const char *host, int *port, int *version, const char *caller) -{ - struct sockaddr_in server_address; - unsigned long inaddr; - struct hostent *hp; - int my_socket; - - if (!*host) - return 0; - - memset ((char *) &server_address, 0, sizeof (server_address)); - server_address.sin_family = AF_INET; - - /* Try to use the dotted decimal number */ - inaddr = inet_addr (host); - if (inaddr != INADDR_NONE) { - memcpy ((char *) &server_address.sin_addr, (char *) &inaddr, - sizeof (inaddr)); - } else { - hp = gethostbyname (host); - if (hp == NULL) { - message (D_ERROR, caller, _("Cannot locate hostname: %s"), - host); - return 0; - } - memcpy ((char *) &server_address.sin_addr, (char *) hp->h_addr, - hp->h_length); - } - - /* Try to contact a remote portmapper to obtain the listening port */ - if (*port == 0) { - *port = mcfs_get_remote_port (&server_address, version); - if (*port < 1) - return 0; - } else - *version = 1; - - server_address.sin_port = htons (*port); - my_socket = socket (AF_INET, SOCK_STREAM, 0); - if (my_socket < 0) { - message (D_ERROR, caller, _("Cannot create socket: %s"), - unix_error_string (errno)); - return 0; - } - if (connect (my_socket, (struct sockaddr *) &server_address, - sizeof (server_address)) < 0) { - message (D_ERROR, caller, _("Cannot connect to server: %s"), - unix_error_string (errno)); - close (my_socket); - return 0; - } - return my_socket; -} - -static int -mcfs_open_tcp_link (char *host, char *user, - int *port, char *netrcpass, int *version) -{ - int my_socket; - int old_port = *port; - - my_socket = mcfs_create_tcp_link (host, port, version, " MCfs "); - if (my_socket <= 0) - return 0; - - /* We got the connection to the server, verify if the server - implements our version of the RPC mechanism and then login - the user. - */ - return mcfs_login_server (my_socket, user, *port, old_port == 0, - netrcpass, version); -} - -static int mcfs_get_free_bucket_init = 1; -static mcfs_connection * -mcfs_get_free_bucket (void) -{ - int i; - - if (mcfs_get_free_bucket_init) { - mcfs_get_free_bucket_init = 0; - for (i = 0; i < MCFS_MAX_CONNECTIONS; i++) - mcfs_connections[i].host = 0; - } - for (i = 0; i < MCFS_MAX_CONNECTIONS; i++) { - if (!mcfs_connections[i].host) - return &mcfs_connections[i]; - } - /* This can't happend, since we have checked for max connections before */ - vfs_die ("Internal error: mcfs_get_free_bucket"); - return 0; /* shut up, stupid gcc */ -} - -/* This routine keeps track of open connections */ -/* Returns a connected socket to host */ -static mcfs_connection * -mcfs_open_link (char *host, char *user, int *port, char *netrcpass) -{ - static int mcfs_open_connections = 0; - int i, sock, version; - mcfs_connection *bucket; - - /* Is the link actually open? */ - if (mcfs_get_free_bucket_init) { - mcfs_get_free_bucket_init = 0; - for (i = 0; i < MCFS_MAX_CONNECTIONS; i++) - mcfs_connections[i].host = 0; - } else - for (i = 0; i < MCFS_MAX_CONNECTIONS; i++) { - if (!mcfs_connections[i].host) - continue; - if ((strcmp (host, mcfs_connections[i].host) == 0) && - (strcmp (user, mcfs_connections[i].user) == 0)) - return &mcfs_connections[i]; - } - if (mcfs_open_connections == MCFS_MAX_CONNECTIONS) { - message (D_ERROR, MSG_ERROR, _("Too many open connections")); - return 0; - } - sock = mcfs_open_tcp_link (host, user, port, netrcpass, &version); - if (sock == 0) - return 0; - - bucket = mcfs_get_free_bucket (); - mcfs_open_connections++; - bucket->host = g_strdup (host); - bucket->user = g_strdup (user); - bucket->home = 0; - bucket->port = *port; - bucket->sock = sock; - bucket->version = version; - - return bucket; -} - -static int -mcfs_is_error (int result, int errno_num) -{ - if (!(result == -1)) - return my_errno = 0; - else - my_errno = errno_num; - return 1; -} - -static int -mcfs_set_error (int result, int errno_num) -{ - if (result == -1) - my_errno = errno_num; - else - my_errno = 0; - return result; -} - -static char * -mcfs_get_path (mcfs_connection **mc, const char *path) -{ - char *user, *host, *remote_path; - char *pass; - int port; - - /* An absolute path name, try to determine connection socket */ - if (strncmp (path, "/#mc:", 5)) - return NULL; - path += 5; - - /* Port = 0 means that mcfs_create_tcp_link will try to contact the - * remote portmapper to get the port number - */ - port = 0; - remote_path = mcfs_get_host_and_username (path, &host, &user, &port, &pass); - if (remote_path != NULL) { - *mc = mcfs_open_link (host, user, &port, pass); - if (*mc == NULL) { - g_free (remote_path); - remote_path = NULL; - } - } - g_free (host); - g_free (user); - if (pass) - wipe_password (pass); - - if (!remote_path) - return NULL; - - /* NOTE: tildes are deprecated. See ftpfs.c */ - { - int f = !strcmp (remote_path, "/~"); - if (f || !strncmp (remote_path, "/~/", 3)) { - char *s; - s = concat_dir_and_file (mcfs_gethome (*mc), - remote_path + 3 - f); - g_free (remote_path); - remote_path = s; - } - } - return remote_path; -} - -/* Simple function for routines returning only an integer from the server */ -static int -mcfs_handle_simple_error (int sock, int return_status) -{ - int status, error; - - if (0 == rpc_get (sock, RPC_INT, &status, RPC_INT, &error, RPC_END)) - return mcfs_set_error (-1, EIO); - - if (mcfs_is_error (status, error)) - return -1; - if (return_status) - return status; - return 0; -} - -/* Nice wrappers */ -static int -mcfs_rpc_two_paths (int command, const char *s1, const char *s2) -{ - mcfs_connection *mc; - char *r1, *r2; - - r1 = mcfs_get_path (&mc, s1); - if (r1 == NULL) - return -1; - - r2 = mcfs_get_path (&mc, s2); - if (r2 == NULL) { - g_free (r1); - return -1; - } - - rpc_send (mc->sock, - RPC_INT, command, RPC_STRING, r1, RPC_STRING, r2, RPC_END); - g_free (r1); - g_free (r2); - return mcfs_handle_simple_error (mc->sock, 0); -} - -static int -mcfs_rpc_path (int command, const char *path) -{ - mcfs_connection *mc; - char *remote_file; - - remote_file = mcfs_get_path (&mc, path); - if (remote_file == NULL) - return -1; - - rpc_send (mc->sock, - RPC_INT, command, RPC_STRING, remote_file, RPC_END); - - g_free (remote_file); - return mcfs_handle_simple_error (mc->sock, 0); -} - -static int -mcfs_rpc_path_int (int command, const char *path, int data) -{ - mcfs_connection *mc; - char *remote_file; - - remote_file = mcfs_get_path (&mc, path); - if (remote_file == NULL) - return -1; - - rpc_send (mc->sock, - RPC_INT, command, - RPC_STRING, remote_file, RPC_INT, data, RPC_END); - - g_free (remote_file); - return mcfs_handle_simple_error (mc->sock, 0); -} - -static int -mcfs_rpc_path_int_int (int command, const char *path, int n1, int n2) -{ - mcfs_connection *mc; - char *remote_file; - - remote_file = mcfs_get_path (&mc, path); - if (remote_file == NULL) - return -1; - - rpc_send (mc->sock, - RPC_INT, command, - RPC_STRING, remote_file, RPC_INT, n1, RPC_INT, n2, RPC_END); - - g_free (remote_file); - return mcfs_handle_simple_error (mc->sock, 0); -} - -static char * -mcfs_gethome (mcfs_connection *mc) -{ - char *buffer; - - if (mc->home) - return g_strdup (mc->home); - else { - rpc_send (mc->sock, RPC_INT, MC_GETHOME, RPC_END); - if (0 == rpc_get (mc->sock, RPC_STRING, &buffer, RPC_END)) - return g_strdup (PATH_SEP_STR); - mc->home = buffer; - return g_strdup (buffer); - } -} - -/* The callbacks */ -static void * -mcfs_open (struct vfs_class *me, const char *file, int flags, int mode) -{ - char *remote_file; - mcfs_connection *mc; - int result, error_num; - mcfs_handle *remote_handle; - - (void) me; - - remote_file = mcfs_get_path (&mc, file); - if (remote_file == NULL) - return 0; - - rpc_send (mc->sock, RPC_INT, MC_OPEN, RPC_STRING, remote_file, RPC_INT, - flags, RPC_INT, mode, RPC_END); - g_free (remote_file); - - if (0 == - rpc_get (mc->sock, RPC_INT, &result, RPC_INT, &error_num, RPC_END)) - return 0; - - if (mcfs_is_error (result, error_num)) - return 0; - - remote_handle = g_new (mcfs_handle, 2); - remote_handle->handle = result; - remote_handle->conn = mc; - - return remote_handle; -} - -static ssize_t -mcfs_read (void *data, char *buffer, int count) -{ - mcfs_handle *info = (mcfs_handle *) data; - int result, error; - int handle; - mcfs_connection *mc; - - mc = info->conn; - handle = info->handle; - - rpc_send (mc->sock, RPC_INT, MC_READ, RPC_INT, handle, - RPC_INT, count, RPC_END); - - if (0 == - rpc_get (mc->sock, RPC_INT, &result, RPC_INT, &error, RPC_END)) - return mcfs_set_error (-1, EIO); - - if (mcfs_is_error (result, error)) - return 0; - - if (0 == rpc_get (mc->sock, RPC_BLOCK, result, buffer, RPC_END)) - return mcfs_set_error (-1, EIO); - - return result; -} - -static ssize_t -mcfs_write (void *data, const char *buf, int nbyte) -{ - mcfs_handle *info = (mcfs_handle *) data; - mcfs_connection *mc; - int handle; - - mc = info->conn; - handle = info->handle; - - rpc_send (mc->sock, - RPC_INT, MC_WRITE, - RPC_INT, handle, - RPC_INT, nbyte, RPC_BLOCK, nbyte, buf, RPC_END); - - return mcfs_handle_simple_error (mc->sock, 1); -} - -static int -mcfs_close (void *data) -{ - mcfs_handle *info = (mcfs_handle *) data; - mcfs_connection *mc; - int handle, result, error; - - if (!data) - return -1; - - handle = info->handle; - mc = info->conn; - - rpc_send (mc->sock, RPC_INT, MC_CLOSE, RPC_INT, handle, RPC_END); - - if (0 == - rpc_get (mc->sock, RPC_INT, &result, RPC_INT, &error, RPC_END)) - return mcfs_set_error (-1, EIO); - - mcfs_is_error (result, error); - - g_free (data); - return result; -} - -static int -mcfs_errno (struct vfs_class *me) -{ - (void) me; - - return my_errno; -} - -typedef struct dir_entry { - char *text; - struct dir_entry *next; - struct stat my_stat; - int merrno; -} dir_entry; - -typedef struct { - mcfs_connection *conn; - int handle; - dir_entry *entries; - dir_entry *current; -} opendir_info; - -static void * -mcfs_opendir (struct vfs_class *me, const char *dirname) -{ - opendir_info *mcfs_info; - mcfs_connection *mc; - int handle, error_num; - char *remote_dir; - int result; - - (void) me; - - remote_dir = mcfs_get_path (&mc, dirname); - if (remote_dir == NULL) - return NULL; - - rpc_send (mc->sock, RPC_INT, MC_OPENDIR, RPC_STRING, remote_dir, - RPC_END); - g_free (remote_dir); - - if (0 == - rpc_get (mc->sock, RPC_INT, &result, RPC_INT, &error_num, RPC_END)) - return NULL; - - if (mcfs_is_error (result, error_num)) - return NULL; - - handle = result; - - mcfs_info = g_new (opendir_info, 1); - mcfs_info->conn = mc; - mcfs_info->handle = handle; - mcfs_info->entries = 0; - mcfs_info->current = 0; - - return (void *) mcfs_info; -} - -static int mcfs_get_stat_info (mcfs_connection * mc, struct stat *buf); - -static int -mcfs_loaddir (opendir_info *mcfs_info) -{ - int status, error; - mcfs_connection *mc = mcfs_info->conn; - int lc_link = mc->sock; - int first = 1; - - rpc_send (lc_link, RPC_INT, MC_READDIR, RPC_INT, mcfs_info->handle, - RPC_END); - - for (;;) { - int entry_len; - dir_entry *new_entry; - - if (!rpc_get (lc_link, RPC_INT, &entry_len, RPC_END)) - return 0; - - if (entry_len == 0) - break; - - new_entry = g_new (dir_entry, 1); - new_entry->text = g_new0 (char, entry_len + 1); - - new_entry->next = 0; - if (first) { - mcfs_info->entries = new_entry; - mcfs_info->current = new_entry; - first = 0; - } else { - mcfs_info->current->next = new_entry; - mcfs_info->current = new_entry; - } - - if (!rpc_get - (lc_link, RPC_BLOCK, entry_len, new_entry->text, RPC_END)) - return 0; - - /* Then we get the status from the lstat */ - if (!rpc_get (lc_link, RPC_INT, &status, RPC_INT, &error, RPC_END)) - return 0; - - if (mcfs_is_error (status, error)) - new_entry->merrno = error; - else { - new_entry->merrno = 0; - if (!mcfs_get_stat_info (mc, &(new_entry->my_stat))) - return 0; - } - } - mcfs_info->current = mcfs_info->entries; - - return 1; -} - -static void -mcfs_free_dir (dir_entry *de) -{ - if (!de) - return; - mcfs_free_dir (de->next); - g_free (de->text); - g_free (de); -} - -static union vfs_dirent mcfs_readdir_data; - -/* The readdir routine loads the complete directory */ -/* It's too slow to ask the server each time */ -/* It now also sends the complete lstat information for each file */ -static struct stat *cached_lstat_info; - -static void * -mcfs_readdir (void *info) -{ - opendir_info *mcfs_info; - char *dirent_dest; - - mcfs_info = (opendir_info *) info; - - if (!mcfs_info->entries) - if (!mcfs_loaddir (mcfs_info)) - return NULL; - - if (mcfs_info->current == 0) { - cached_lstat_info = 0; - mcfs_free_dir (mcfs_info->entries); - mcfs_info->entries = 0; - return NULL; - } - dirent_dest = mcfs_readdir_data.dent.d_name; - g_strlcpy (dirent_dest, mcfs_info->current->text, MC_MAXPATHLEN); - cached_lstat_info = &mcfs_info->current->my_stat; - mcfs_info->current = mcfs_info->current->next; - - compute_namelen (&mcfs_readdir_data.dent); - - return &mcfs_readdir_data; -} - -static int -mcfs_closedir (void *info) -{ - opendir_info *mcfs_info = (opendir_info *) info; - dir_entry *p, *q; - - rpc_send (mcfs_info->conn->sock, RPC_INT, MC_CLOSEDIR, - RPC_INT, mcfs_info->handle, RPC_END); - - for (p = mcfs_info->entries; p;) { - q = p; - p = p->next; - g_free (q->text); - g_free (q); - } - g_free (info); - return 0; -} - -static time_t -mcfs_get_time (mcfs_connection *mc) -{ - int sock = mc->sock; - - if (mc->version == 1) { - struct tm tt; - - rpc_get (sock, - RPC_INT, &tt.tm_sec, - RPC_INT, &tt.tm_min, - RPC_INT, &tt.tm_hour, - RPC_INT, &tt.tm_mday, - RPC_INT, &tt.tm_year, RPC_INT, &tt.tm_mon, RPC_END); - tt.tm_year -= 1900; - tt.tm_isdst = 0; - - return mktime (&tt); - } else { - char *buf; - long tm; - - rpc_get (sock, RPC_STRING, &buf, RPC_END); - sscanf (buf, "%lx", &tm); - g_free (buf); - - return (time_t) tm; - } -} - -static int -mcfs_get_stat_info (mcfs_connection *mc, struct stat *buf) -{ - long mylong; - int sock = mc->sock; - - buf->st_dev = 0; - - rpc_get (sock, RPC_INT, &mylong, RPC_END); -#ifdef HAVE_STRUCT_STAT_ST_RDEV - buf->st_rdev = mylong; -#endif - rpc_get (sock, RPC_INT, &mylong, RPC_END); - buf->st_ino = mylong; - rpc_get (sock, RPC_INT, &mylong, RPC_END); - buf->st_mode = mylong; - rpc_get (sock, RPC_INT, &mylong, RPC_END); - buf->st_nlink = mylong; - rpc_get (sock, RPC_INT, &mylong, RPC_END); - buf->st_uid = mylong; - rpc_get (sock, RPC_INT, &mylong, RPC_END); - buf->st_gid = mylong; - rpc_get (sock, RPC_INT, &mylong, RPC_END); - buf->st_size = mylong; - - if (!rpc_get (sock, RPC_INT, &mylong, RPC_END)) - return 0; -#ifdef HAVE_STRUCT_STAT_ST_BLOCKS - buf->st_blocks = mylong; -#endif - buf->st_atime = mcfs_get_time (mc); - buf->st_mtime = mcfs_get_time (mc); - buf->st_ctime = mcfs_get_time (mc); - return 1; -} - -static int -mcfs_stat_cmd (int cmd, const char *path, struct stat *buf) -{ - char *remote_file; - mcfs_connection *mc; - int status, error; - - remote_file = mcfs_get_path (&mc, path); - if (remote_file == NULL) - return -1; - - rpc_send (mc->sock, RPC_INT, cmd, RPC_STRING, remote_file, RPC_END); - g_free (remote_file); - if (!rpc_get (mc->sock, RPC_INT, &status, RPC_INT, &error, RPC_END)) - return mcfs_set_error (-1, errno); - - if (mcfs_is_error (status, error)) - return -1; - - if (mcfs_get_stat_info (mc, buf)) - return 0; - else - return mcfs_set_error (-1, EIO); -} - -static int -mcfs_stat (struct vfs_class *me, const char *path, struct stat *buf) -{ - (void) me; - - return mcfs_stat_cmd (MC_STAT, path, buf); -} - -static int -mcfs_lstat (struct vfs_class *me, const char *path, struct stat *buf) -{ - int path_len = strlen (path); - int entry_len = strlen (mcfs_readdir_data.dent.d_name); - - (void) me; - - /* Hack ... */ - if (strcmp (path + path_len - entry_len, - mcfs_readdir_data.dent.d_name) == 0 && cached_lstat_info) { - *buf = *cached_lstat_info; - return 0; - } - return mcfs_stat_cmd (MC_LSTAT, path, buf); -} - -static int -mcfs_fstat (void *data, struct stat *buf) -{ - mcfs_handle *info = (mcfs_handle *) data; - int result, error; - int handle, sock; - - sock = info->conn->sock; - handle = info->handle; - - rpc_send (sock, RPC_INT, MC_FSTAT, RPC_INT, handle, RPC_END); - if (!rpc_get (sock, RPC_INT, &result, RPC_INT, &error, RPC_END)) - return mcfs_set_error (-1, EIO); - - if (mcfs_is_error (result, error)) - return -1; - - if (mcfs_get_stat_info (info->conn, buf)) - return 0; - else - return mcfs_set_error (-1, EIO); -} - -static int -mcfs_chmod (struct vfs_class *me, const char *path, int mode) -{ - (void) me; - - return mcfs_rpc_path_int (MC_CHMOD, path, mode); -} - -static int -mcfs_chown (struct vfs_class *me, const char *path, int owner, int group) -{ - (void) me; - - return mcfs_rpc_path_int_int (MC_CHOWN, path, owner, group); -} - -static int -mcfs_utime (struct vfs_class *me, const char *path, struct utimbuf *times) -{ - mcfs_connection *mc; - int status; - char *file; - - (void) me; - - file = mcfs_get_path (&mc, path); - if (file == NULL) - return -1; - - status = 0; - if (mc->version >= 2) { - char abuf[BUF_SMALL]; - char mbuf[BUF_SMALL]; - long atime, mtime; - - atime = (long) times->actime; - mtime = (long) times->modtime; - - g_snprintf (abuf, sizeof (abuf), "%lx", atime); - g_snprintf (mbuf, sizeof (mbuf), "%lx", mtime); - - rpc_send (mc->sock, RPC_INT, MC_UTIME, - RPC_STRING, file, - RPC_STRING, abuf, RPC_STRING, mbuf, RPC_END); - status = mcfs_handle_simple_error (mc->sock, 0); - - } - g_free (file); - return (status); -} - -static int -mcfs_readlink (struct vfs_class *me, const char *path, char *buf, size_t size) -{ - char *remote_file, *stat_str; - int status, error; - mcfs_connection *mc; - size_t len; - - (void) me; - - remote_file = mcfs_get_path (&mc, path); - if (remote_file == NULL) - return -1; - - rpc_send (mc->sock, RPC_INT, MC_READLINK, RPC_STRING, remote_file, - RPC_END); - g_free (remote_file); - if (!rpc_get (mc->sock, RPC_INT, &status, RPC_INT, &error, RPC_END)) - return mcfs_set_error (-1, EIO); - - if (mcfs_is_error (status, errno)) - return -1; - - if (!rpc_get (mc->sock, RPC_STRING, &stat_str, RPC_END)) - return mcfs_set_error (-1, EIO); - - len = strlen (stat_str); - if (len < size) - size = len; - /* readlink() does not append a NUL character to buf */ - memcpy (buf, stat_str, size); - g_free (stat_str); - return size; -} - -static int -mcfs_unlink (struct vfs_class *me, const char *path) -{ - (void) me; - - return mcfs_rpc_path (MC_UNLINK, path); -} - -static int -mcfs_symlink (struct vfs_class *me, const char *n1, const char *n2) -{ - (void) me; - - return mcfs_rpc_two_paths (MC_SYMLINK, n1, n2); -} - -static int -mcfs_rename (struct vfs_class *me, const char *a, const char *b) -{ - (void) me; - - return mcfs_rpc_two_paths (MC_RENAME, a, b); -} - -static int -mcfs_chdir (struct vfs_class *me, const char *path) -{ - char *remote_dir; - mcfs_connection *mc; - int status, error; - - (void) me; - - remote_dir = mcfs_get_path (&mc, path); - if (remote_dir == NULL) - return -1; - - rpc_send (mc->sock, RPC_INT, MC_CHDIR, RPC_STRING, remote_dir, - RPC_END); - g_free (remote_dir); - if (!rpc_get (mc->sock, RPC_INT, &status, RPC_INT, &error, RPC_END)) - return mcfs_set_error (-1, EIO); - - if (mcfs_is_error (status, error)) - return -1; - return 0; -} - -static off_t -mcfs_lseek (void *data, off_t offset, int whence) -{ - mcfs_handle *info = (mcfs_handle *) data; - int handle, sock; - - sock = info->conn->sock; - handle = info->handle; - - /* FIXME: off_t may be too long to fit */ - rpc_send (sock, RPC_INT, MC_LSEEK, RPC_INT, handle, RPC_INT, - (int) offset, RPC_INT, whence, RPC_END); - - return mcfs_handle_simple_error (sock, 1); -} - -static int -mcfs_mknod (struct vfs_class *me, const char *path, int mode, int dev) -{ - (void) me; - - return mcfs_rpc_path_int_int (MC_MKNOD, path, mode, dev); -} - -static int -mcfs_mkdir (struct vfs_class *me, const char *path, mode_t mode) -{ - (void) me; - - return mcfs_rpc_path_int (MC_MKDIR, path, mode); -} - -static int -mcfs_rmdir (struct vfs_class *me, const char *path) -{ - (void) me; - - return mcfs_rpc_path (MC_RMDIR, path); -} - -static int -mcfs_link (struct vfs_class *me, const char *p1, const char *p2) -{ - (void) me; - - return mcfs_rpc_two_paths (MC_LINK, p1, p2); -} - -/* Gives up on a socket and reopens the connection, the child own the socket - * now - */ -static void -mcfs_forget (const char *path) -{ - char *host, *user, *pass, *p; - int port, i, vers; - - if (strncmp (path, "/#mc:", 5)) - return; - - path += 5; - if ((path[0] == '/') && (path[1] == '/')) - path += 2; - - p = mcfs_get_host_and_username (path, &host, &user, &port, &pass); - if (p == NULL) { - g_free (host); - g_free (user); - if (pass) - wipe_password (pass); - return; - } - for (i = 0; i < MCFS_MAX_CONNECTIONS; i++) { - if ((strcmp (host, mcfs_connections[i].host) == 0) && - (strcmp (user, mcfs_connections[i].user) == 0) && - (port == mcfs_connections[i].port)) { - - /* close socket: the child owns it now */ - close (mcfs_connections[i].sock); - - /* reopen the connection */ - mcfs_connections[i].sock = - mcfs_open_tcp_link (host, user, &port, pass, &vers); - } - } - g_free (p); - g_free (host); - g_free (user); - if (pass) - wipe_password (pass); -} - -static int -mcfs_setctl (struct vfs_class *me, const char *path, int ctlop, void *arg) -{ - (void) me; - (void) arg; - - switch (ctlop) { - case VFS_SETCTL_FORGET: - mcfs_forget (path); - return 0; - } - return 0; -} - -void -init_mcfs (void) -{ - tcp_init(); - - vfs_mcfs_ops.name = "mcfs"; - vfs_mcfs_ops.prefix = "mc:"; - vfs_mcfs_ops.fill_names = mcfs_fill_names; - vfs_mcfs_ops.open = mcfs_open; - vfs_mcfs_ops.close = mcfs_close; - vfs_mcfs_ops.read = mcfs_read; - vfs_mcfs_ops.write = mcfs_write; - vfs_mcfs_ops.opendir = mcfs_opendir; - vfs_mcfs_ops.readdir = mcfs_readdir; - vfs_mcfs_ops.closedir = mcfs_closedir; - vfs_mcfs_ops.stat = mcfs_stat; - vfs_mcfs_ops.lstat = mcfs_lstat; - vfs_mcfs_ops.fstat = mcfs_fstat; - vfs_mcfs_ops.chmod = mcfs_chmod; - vfs_mcfs_ops.chown = mcfs_chown; - vfs_mcfs_ops.utime = mcfs_utime; - vfs_mcfs_ops.readlink = mcfs_readlink; - vfs_mcfs_ops.symlink = mcfs_symlink; - vfs_mcfs_ops.link = mcfs_link; - vfs_mcfs_ops.unlink = mcfs_unlink; - vfs_mcfs_ops.rename = mcfs_rename; - vfs_mcfs_ops.chdir = mcfs_chdir; - vfs_mcfs_ops.ferrno = mcfs_errno; - vfs_mcfs_ops.lseek = mcfs_lseek; - vfs_mcfs_ops.mknod = mcfs_mknod; - vfs_mcfs_ops.mkdir = mcfs_mkdir; - vfs_mcfs_ops.rmdir = mcfs_rmdir; - vfs_mcfs_ops.setctl = mcfs_setctl; - vfs_register_class (&vfs_mcfs_ops); -} - -static void -mcfs_free_bucket (int bucket) -{ - g_free (mcfs_connections[bucket].host); - g_free (mcfs_connections[bucket].user); - g_free (mcfs_connections[bucket].home); - - /* Set all the fields to zero */ - mcfs_connections[bucket].host = - mcfs_connections[bucket].user = mcfs_connections[bucket].home = 0; - mcfs_connections[bucket].sock = mcfs_connections[bucket].version = 0; -} - -static int -mcfs_invalidate_socket (int sock) -{ - int i, j = -1; - - for (i = 0; i < MCFS_MAX_CONNECTIONS; i++) - if (mcfs_connections[i].sock == sock) { - mcfs_free_bucket (i); - j = 0; - } - - if (j == -1) - return -1; /* It was not our sock */ - /* Break from any possible loop */ - mc_chdir ("/"); - return 0; -} - -void -tcp_invalidate_socket (int sock) -{ - mcfs_invalidate_socket (sock); -} -#endif /* ENABLE_VFS_MCFS */ diff --git a/lib/vfs/mc-vfs/mcfs.h b/lib/vfs/mc-vfs/mcfs.h deleted file mode 100644 index 6b864d6ed..000000000 --- a/lib/vfs/mc-vfs/mcfs.h +++ /dev/null @@ -1,62 +0,0 @@ - -/** - * \file - * \brief Header: Midnight Commander file system - */ - -#ifndef MC_VFS_MCFS_H -#define MC_VFS_MCFS_H - -#define mcserver_port 9876 - -/* This number was registered for program "mcfs" with rpc@Sun.COM */ -#define RPC_PROGNUM 300516 -#define RPC_PROGVER 2 - -/* this constants must be kept in sync with mcserv.c commands */ -/* They are the messages sent on the link connection */ -enum { - MC_OPEN, - MC_CLOSE, - MC_READ, - MC_WRITE, - MC_OPENDIR, - MC_READDIR, - MC_CLOSEDIR, - MC_STAT, - MC_LSTAT, - MC_FSTAT, - MC_CHMOD, - MC_CHOWN, - MC_READLINK, - MC_UNLINK, - MC_RENAME, - MC_CHDIR, - MC_LSEEK, - MC_RMDIR, - MC_SYMLINK, - MC_MKNOD, - MC_MKDIR, - MC_LINK, - MC_GETHOME, - MC_GETUPDIR, - - /* Control commands */ - MC_LOGIN, - MC_QUIT, - - MC_UTIME, /* it has to go here for compatibility with old - servers/clients. sigh ... */ - - MC_INVALID_PASS = 0x1000, - MC_NEED_PASSWORD, - MC_LOGINOK, - MC_VERSION_OK, - MC_VERSION_MISMATCH, - MC_PASS -}; - -extern void init_mcfs (void); -extern void tcp_invalidate_socket (int); - -#endif diff --git a/lib/vfs/mc-vfs/mcfsutil.c b/lib/vfs/mc-vfs/mcfsutil.c deleted file mode 100644 index e3bf089ec..000000000 --- a/lib/vfs/mc-vfs/mcfsutil.c +++ /dev/null @@ -1,241 +0,0 @@ -/* Low-level protocol for MCFS. - - Copyright (C) 1995, 1996 Miguel de Icaza - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ - -/** - * \file - * \brief Source: Low-level protocol for MCFS - * \author Miguel de Icaza - * \date 1995, 1996 - */ - -#include - -#if defined(ENABLE_VFS_MCFS) || defined(ENABLE_MCSERVER) -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef HAVE_ARPA_INET_H -#include -#endif - -#ifdef HAVE_PMAP_SET -#include -#include -#ifdef HAVE_RPC_PMAP_CLNT_H -#include -#endif -#endif - -#include - -#include "lib/global.h" -#include "src/wtools.h" /* message() */ -#include "src/main.h" /* print_vfs_message */ -#include "utilvfs.h" -#include "mcfsutil.h" -#include "netutil.h" -#include "mcfs.h" /* tcp_invalidate_socket() */ - -#define CHECK_SIG_PIPE(sock) if (got_sigpipe) \ - { tcp_invalidate_socket (sock); return got_sigpipe = 0; } - -/* Reads a block on dest for len bytes from sock */ -/* Returns a boolean indicating the success status */ -int -socket_read_block (int sock, char *dest, int len) -{ - int nread, n; - - for (nread = 0; nread < len;) - { - n = read (sock, dest + nread, len - nread); - if (n <= 0) - { - tcp_invalidate_socket (sock); - return 0; - } - nread += n; - } - return 1; -} - -int -socket_write_block (int sock, const char *buffer, int len) -{ - int left, status; - - for (left = len; left > 0;) - { - status = write (sock, buffer, left); - CHECK_SIG_PIPE (sock); - if (status < 0) - return 0; - left -= status; - buffer += status; - } - return 1; -} - -int -rpc_send (int sock, ...) -{ - long int tmp, len, cmd; - char *text; - va_list ap; - - va_start (ap, sock); - - for (;;) - { - cmd = va_arg (ap, int); - switch (cmd) - { - case RPC_END: - va_end (ap); - return 1; - - case RPC_INT: - tmp = htonl (va_arg (ap, int)); - if (write (sock, &tmp, sizeof (tmp)) != sizeof (tmp)) - { - vfs_die ("RPC: write failed (RPC_INT)"); - break; - } - CHECK_SIG_PIPE (sock); - break; - - case RPC_STRING: - text = va_arg (ap, char *); - len = strlen (text); - tmp = htonl (len); - if (write (sock, &tmp, sizeof (tmp)) != sizeof (tmp)) - { - vfs_die ("RPC: write failed (RPC_STRING)"); - break; - } - CHECK_SIG_PIPE (sock); - if (write (sock, text, len) != len) - { - vfs_die ("RPC: write failed (RPC_STRING)"); - break; - } - CHECK_SIG_PIPE (sock); - break; - - case RPC_BLOCK: - len = va_arg (ap, int); - text = va_arg (ap, char *); - tmp = htonl (len); - if (write (sock, text, len) != len) - { - vfs_die ("RPC: write failed (RPC_BLOCK)"); - break; - } - CHECK_SIG_PIPE (sock); - break; - - default: - vfs_die ("Unknown rpc message\n"); - } - } -} - -int -rpc_get (int sock, ...) -{ - long int tmp, len; - char *text, **str_dest; - int *dest, cmd; - va_list ap; - - va_start (ap, sock); - - for (;;) - { - cmd = va_arg (ap, int); - switch (cmd) - { - case RPC_END: - va_end (ap); - return 1; - - case RPC_INT: - if (socket_read_block (sock, (char *) &tmp, sizeof (tmp)) == 0) - { - va_end (ap); - return 0; - } - dest = va_arg (ap, int *); - *dest = ntohl (tmp); - break; - - /* returns an allocated string */ - case RPC_LIMITED_STRING: - case RPC_STRING: - if (socket_read_block (sock, (char *) &tmp, sizeof (tmp)) == 0) - { - va_end (ap); - return 0; - } - len = ntohl (tmp); - if (cmd == RPC_LIMITED_STRING) - if (len > 16 * 1024) - { - /* silently die */ - abort (); - } - if (len > 128 * 1024) - abort (); - - /* Don't use glib functions here - this code is used by mcserv */ - text = malloc (len + 1); - if (socket_read_block (sock, text, len) == 0) - { - free (text); - va_end (ap); - return 0; - } - text[len] = '\0'; - - str_dest = va_arg (ap, char **); - *str_dest = text; - break; - - case RPC_BLOCK: - len = va_arg (ap, int); - text = va_arg (ap, char *); - if (socket_read_block (sock, text, len) == 0) - { - va_end (ap); - return 0; - } - break; - - default: - vfs_die ("Unknown rpc message\n"); - } - } -} -#endif /* ENABLE_VFS_MCFS || ENABLE_MCSERVER */ diff --git a/lib/vfs/mc-vfs/mcfsutil.h b/lib/vfs/mc-vfs/mcfsutil.h deleted file mode 100644 index 9e1d89902..000000000 --- a/lib/vfs/mc-vfs/mcfsutil.h +++ /dev/null @@ -1,29 +0,0 @@ - -/** - * \file - * \brief Header: Low-level protocol for MCFS - * - * \todo FIXME: This protocol uses 32-bit integers for the communication. - * It is a problem on systems with large file support, which is now - * default. This means that lseek is broken unless --disable-largefile - * is used. 64-bit systems are probably broken even more. - */ - -#ifndef MC_VFS_MCFSUTIL_H -#define MC_VFS_MCFSUTIL_H - - -enum { - RPC_END, /* End of RPC commands */ - RPC_INT, /* Next argument is integer */ - RPC_STRING, /* Next argument is a string */ - RPC_BLOCK, /* Next argument is a len/block */ - RPC_LIMITED_STRING /* same as STRING, but has a size limit */ -}; - -int rpc_get (int sock, ...); -int rpc_send (int sock, ...); -int socket_read_block (int sock, char *dest, int len); -int socket_write_block (int sock, const char *buffer, int len); - -#endif diff --git a/lib/vfs/mc-vfs/mcserv.c b/lib/vfs/mc-vfs/mcserv.c deleted file mode 100644 index d0c6730a9..000000000 --- a/lib/vfs/mc-vfs/mcserv.c +++ /dev/null @@ -1,1399 +0,0 @@ -/* Server for the Midnight Commander Virtual File System. - - Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, - 2004, 2005, 2006, 2007 Free Software Foundation, Inc. - - Written by: - Miguel de Icaza, 1995, 1997, - Andrej Borsenkow 1996. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -/** - * \file - * \brief Source: server for the Midnight Commander Virtual File System - * \author Miguel de Icaza - * \author Andrej Borsenkow - * \date 1995, 1996, 1997 - * - * \todo opendir instead of keeping its table of file handles could return - * the pointer and expect the client to send a proper value back each - * time :-) We should use syslog to register login/logout. - */ - -/* {{{ Includes and global variables */ - -#include - -#include -#include -#include -#include -#include -#ifdef HAVE_LIMITS_H -# include -#endif -#ifndef NGROUPS_MAX -# include -# ifdef NGROUPS -# define NGROUPS_MAX NGROUPS -# endif -#endif -#include -#include -#include -#include -#include -#include -#include -#ifdef HAVE_GETOPT_H -# include -#endif - -/* Network include files */ -#include -#include -#include -#ifdef HAVE_ARPA_INET_H -#include -#endif -#ifdef HAVE_PMAP_SET -# include -# include -# ifdef HAVE_RPC_PMAP_CLNT_H -# include -# endif -#endif - -#if defined(HAVE_PAM) -# if !defined(HAVE_SECURITY_PAM_MISC_H) -# undef HAVE_PAM -# endif -#endif - -/* Authentication include files */ -#include -#ifdef HAVE_PAM -# include -# ifndef PAM_ESTABLISH_CRED -# define PAM_ESTABLISH_CRED PAM_CRED_ESTABLISH -# endif -#else -#endif /* !HAVE_PAM */ - -#ifdef HAVE_CRYPT_H -# include -#endif /* !HAVE_CRYPT_H */ - -#ifdef HAVE_SHADOW_H -# include -#else -# ifdef HAVE_SHADOW_SHADOW_H -# include -# endif -#endif - -/* - * GNU gettext defines printf to libintl_printf on platforms that lack - * a native printf(3) capable of all POSIX features. - */ -#undef ENABLE_NLS -#include "lib/global.h" - -#include "src/wtools.h" /* message() */ -#include "src/main.h" /* print_vfs_message */ -#include "utilvfs.h" -#include "vfs.h" -#include "mcfs.h" -#include "mcfsutil.h" -#include "netutil.h" - -#ifndef INADDR_NONE -# define INADDR_NONE (0xffffffffU) -#endif - -/* replacement for g_free() from glib */ -#undef g_free -#define g_free(x) do {if (x) free (x);} while (0) - -/* We don't care about SIGPIPE */ -int got_sigpipe = 0; - -/* The socket from which we accept commands */ -int msock; - -/* Requested version number from client */ -static int clnt_version; - -/* If non zero, we accept further commands */ -int logged_in = 0; - -/* Home directory */ -const char *home_dir = NULL; - -char *up_dir = NULL; - -/* Were we started from inetd? */ -int inetd_started = 0; - -/* Are we running as a daemon? */ -int isDaemon = 0; - -/* guess */ -int verbose = 0; - -/* ftp auth */ -int ftp = 0; - -/* port number in which we listen to connections, - * if zero, we try to contact the portmapper to get a port, and - * if it's not possible, then we use a hardcoded value - */ -int portnum = 0; - -/* if the server will use rcmd based authentication (hosts.equiv .rhosts) */ -int r_auth = 0; - -#define OPENDIR_HANDLES 8 - -#define DO_QUIT_VOID() \ -do { \ - quit_server = 1; \ - return_code = 1; \ - return; \ -} while (0) - -/* Only used by get_port_number */ -#define DO_QUIT_NONVOID(a) \ -do { \ - quit_server = 1; \ - return_code = 1; \ - return (a); \ -} while (0) - -char buffer[4096]; -int debug = 1; -static int quit_server; -static int return_code; - -/* }}} */ - -/* {{{ Misc routines */ - -static void -send_status (int status, int errno_number) -{ - rpc_send (msock, RPC_INT, status, RPC_INT, errno_number, RPC_END); - errno = 0; -} - -/* }}} */ - -/* {{{ File with handle operations */ - -static void -do_open (void) -{ - int handle, flags, mode; - char *arg; - - rpc_get (msock, RPC_STRING, &arg, RPC_INT, &flags, RPC_INT, &mode, - RPC_END); - - handle = open (arg, flags, mode); - send_status (handle, errno); - g_free (arg); -} - -static void -do_read (void) -{ - int handle, count, n; - void *data; - - rpc_get (msock, RPC_INT, &handle, RPC_INT, &count, RPC_END); - data = malloc (count); - if (data == NULL) { - send_status (-1, ENOMEM); - return; - } - if (verbose) - printf ("count=%d\n", count); - n = read (handle, data, count); - if (verbose) - printf ("result=%d\n", n); - if (n < 0) - send_status (-1, errno); - else { - send_status (n, 0); - rpc_send (msock, RPC_BLOCK, n, data, RPC_END); - } - - g_free (data); -} - -static void -do_write (void) -{ - int handle, count, status, written = 0; - char buf[8192]; - - rpc_get (msock, RPC_INT, &handle, RPC_INT, &count, RPC_END); - status = 0; - while (count) { - int nbytes = count > 8192 ? 8192 : count; - - rpc_get (msock, RPC_BLOCK, nbytes, buf, RPC_END); - status = write (handle, buf, nbytes); - if (status < 0) { - send_status (status, errno); - return; - } - /* FIXED: amount written must be returned to caller */ - written += status; - if (status < nbytes) { - send_status (written, errno); - return; - } - count -= nbytes; - } - send_status (written, errno); -} - -static void -do_lseek (void) -{ - int handle, offset, whence, status; - - rpc_get (msock, RPC_INT, &handle, RPC_INT, &offset, RPC_INT, &whence, - RPC_END); - status = lseek (handle, offset, whence); - send_status (status, errno); -} - -static void -do_close (void) -{ - int handle, status; - - rpc_get (msock, RPC_INT, &handle, RPC_END); - status = close (handle); - send_status (status, errno); -} - -/* }}} */ - -/* {{{ Stat family routines */ - -static void -send_time (int sock, time_t t) -{ - if (clnt_version == 1) { - char *ct; - int month; - - ct = ctime (&t); - ct[3] = ct[10] = ct[13] = ct[16] = ct[19] = 0; - - /* Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec */ - if (ct[4] == 'J') { - if (ct[5] == 'a') { - month = 0; - } else - month = (ct[6] == 'n') ? 5 : 6; - } else if (ct[4] == 'F') { - month = 1; - } else if (ct[4] == 'M') { - month = (ct[6] == 'r') ? 2 : 5; - } else if (ct[4] == 'A') { - month = (ct[5] == 'p') ? 3 : 7; - } else if (ct[4] == 'S') { - month = 8; - } else if (ct[4] == 'O') { - month = 9; - } else if (ct[4] == 'N') { - month = 10; - } else - month = 11; - rpc_send (sock, RPC_INT, atoi (&ct[17]), /* sec */ - RPC_INT, atoi (&ct[14]), /* min */ - RPC_INT, atoi (&ct[11]), /* hour */ - RPC_INT, atoi (&ct[8]), /* mday */ - RPC_INT, atoi (&ct[20]), /* year */ - RPC_INT, month, /* month */ - RPC_END); - } else { - long ltime = (long) t; - char buf[BUF_SMALL]; - - g_snprintf (buf, sizeof (buf), "%lx", ltime); - rpc_send (sock, RPC_STRING, buf, RPC_END); - } -} - -static void -send_stat_info (struct stat *st) -{ - long mylong; - int blocks = -#ifdef HAVE_STRUCT_STAT_ST_BLOCKS - st->st_blocks; -#else - st->st_size / 1024; -#endif - -#ifdef HAVE_STRUCT_STAT_ST_RDEV - mylong = st->st_rdev; -#else - mylong = 0; -#endif - rpc_send (msock, RPC_INT, (long) mylong, RPC_INT, (long) st->st_ino, - RPC_INT, (long) st->st_mode, RPC_INT, (long) st->st_nlink, - RPC_INT, (long) st->st_uid, RPC_INT, (long) st->st_gid, - RPC_INT, (long) st->st_size, RPC_INT, (long) blocks, - RPC_END); - send_time (msock, st->st_atime); - send_time (msock, st->st_mtime); - send_time (msock, st->st_ctime); -} - -static void -do_lstat (void) -{ - struct stat st; - char *file; - int n; - - rpc_get (msock, RPC_STRING, &file, RPC_END); - n = lstat (file, &st); - send_status (n, errno); - if (n >= 0) - send_stat_info (&st); - g_free (file); -} - -static void -do_fstat (void) -{ - int handle; - int n; - struct stat st; - - rpc_get (msock, RPC_INT, &handle, RPC_END); - n = fstat (handle, &st); - send_status (n, errno); - if (n < 0) - return; - - send_stat_info (&st); -} - -static void -do_stat (void) -{ - struct stat st; - int n; - char *file; - - rpc_get (msock, RPC_STRING, &file, RPC_END); - - n = stat (file, &st); - send_status (n, errno); - if (n >= 0) - send_stat_info (&st); - g_free (file); -} - -/* }}} */ - -/* {{{ Directory lookup operations */ - -static struct { - int used; - DIR *dirs[OPENDIR_HANDLES]; - char *names[OPENDIR_HANDLES]; -} mcfs_DIR; - -static void -close_handle (int handle) -{ - if (mcfs_DIR.used > 0) - mcfs_DIR.used--; - if (mcfs_DIR.dirs[handle]) - closedir (mcfs_DIR.dirs[handle]); - g_free (mcfs_DIR.names[handle]); - mcfs_DIR.dirs[handle] = 0; - mcfs_DIR.names[handle] = 0; -} - -static void -do_opendir (void) -{ - int handle, i; - char *arg; - DIR *p; - - rpc_get (msock, RPC_STRING, &arg, RPC_END); - - if (mcfs_DIR.used == OPENDIR_HANDLES) { - send_status (-1, ENFILE); /* Error */ - g_free (arg); - return; - } - - handle = -1; - for (i = 0; i < OPENDIR_HANDLES; i++) { - if (mcfs_DIR.dirs[i] == 0) { - handle = i; - break; - } - } - - if (handle == -1) { - send_status (-1, EMFILE); - g_free (arg); - if (!inetd_started) - fprintf (stderr, - "OOPS! you have found a bug in mc - do_opendir()!\n"); - return; - } - - if (verbose) - printf ("handle=%d\n", handle); - p = opendir (arg); - if (p) { - mcfs_DIR.dirs[handle] = p; - mcfs_DIR.names[handle] = arg; - mcfs_DIR.used++; - - /* Because 0 is an error value */ - rpc_send (msock, RPC_INT, handle + 1, RPC_INT, 0, RPC_END); - - } else { - send_status (-1, errno); - g_free (arg); - } -} - -/* Sends the complete directory listing, as well as the stat information */ -static void -do_readdir (void) -{ - struct dirent *dirent; - struct stat st; - int handle, n; - - rpc_get (msock, RPC_INT, &handle, RPC_END); - - if (!handle) { - rpc_send (msock, RPC_INT, 0, RPC_END); - return; - } - - /* We incremented it in opendir */ - handle--; - - while ((dirent = readdir (mcfs_DIR.dirs[handle]))) { - int fname_len; - char *fname; - int length = NLENGTH (dirent); - - rpc_send (msock, RPC_INT, length, RPC_END); - rpc_send (msock, RPC_BLOCK, length, dirent->d_name, RPC_END); - fname_len = - strlen (mcfs_DIR.names[handle]) + strlen (dirent->d_name) + 2; - fname = malloc (fname_len); - g_snprintf (fname, fname_len, "%s/%s", mcfs_DIR.names[handle], - dirent->d_name); - n = lstat (fname, &st); - g_free (fname); - send_status (n, errno); - if (n >= 0) - send_stat_info (&st); - } - rpc_send (msock, RPC_INT, 0, RPC_END); -} - -static void -do_closedir (void) -{ - int handle; - - rpc_get (msock, RPC_INT, &handle, RPC_END); - close_handle (handle - 1); -} - -/* }}} */ - -/* {{{ Operations with one and two file name argument */ - -static void -do_chdir (void) -{ - char *file; - int status; - - rpc_get (msock, RPC_STRING, &file, RPC_END); - - status = chdir (file); - send_status (status, errno); - g_free (file); -} - -static void -do_rmdir (void) -{ - char *file; - int status; - - rpc_get (msock, RPC_STRING, &file, RPC_END); - - status = rmdir (file); - send_status (status, errno); - g_free (file); -} - -static void -do_mkdir (void) -{ - char *file; - int mode, status; - - rpc_get (msock, RPC_STRING, &file, RPC_INT, &mode, RPC_END); - - status = mkdir (file, mode); - send_status (status, errno); - g_free (file); -} - -static void -do_mknod (void) -{ - char *file; - int mode, dev, status; - - rpc_get (msock, RPC_STRING, &file, RPC_INT, &mode, RPC_INT, &dev, - RPC_END); - - status = mknod (file, mode, dev); - send_status (status, errno); - g_free (file); -} - -static void -do_readlink (void) -{ - char buf[2048]; - char *file; - int n; - - rpc_get (msock, RPC_STRING, &file, RPC_END); - n = readlink (file, buf, 2048 - 1); - send_status (n, errno); - if (n >= 0) { - buf[n] = 0; - rpc_send (msock, RPC_STRING, buf, RPC_END); - } - g_free (file); -} - -static void -do_unlink (void) -{ - char *file; - int status; - - rpc_get (msock, RPC_STRING, &file, RPC_END); - status = unlink (file); - send_status (status, errno); - g_free (file); -} - -static void -do_rename (void) -{ - char *f1, *f2; - int status; - - rpc_get (msock, RPC_STRING, &f1, RPC_STRING, &f2, RPC_END); - status = rename (f1, f2); - send_status (status, errno); - g_free (f1); - g_free (f2); -} - -static void -do_symlink (void) -{ - char *f1, *f2; - int status; - - rpc_get (msock, RPC_STRING, &f1, RPC_STRING, &f2, RPC_END); - status = symlink (f1, f2); - send_status (status, errno); - g_free (f1); - g_free (f2); -} - -static void -do_link (void) -{ - char *f1, *f2; - int status; - - rpc_get (msock, RPC_STRING, &f1, RPC_STRING, &f2, RPC_END); - status = link (f1, f2); - send_status (status, errno); - g_free (f1); - g_free (f2); -} - - -/* }}} */ - -/* {{{ Misc commands */ - -static void -do_gethome (void) -{ - rpc_send (msock, RPC_STRING, (home_dir) ? home_dir : "/", RPC_END); -} - -static void -do_getupdir (void) -{ - rpc_send (msock, RPC_STRING, (up_dir) ? up_dir : "/", RPC_END); -} - -static void -do_chmod (void) -{ - char *file; - int mode, status; - - rpc_get (msock, RPC_STRING, &file, RPC_INT, &mode, RPC_END); - status = chmod (file, mode); - send_status (status, errno); - g_free (file); -} - -static void -do_chown (void) -{ - char *file; - int owner, group, status; - - rpc_get (msock, RPC_STRING, &file, RPC_INT, &owner, RPC_INT, &group, - RPC_END); - status = chown (file, owner, group); - send_status (status, errno); - g_free (file); -} - -static void -do_utime (void) -{ - char *file; - int status; - long atime; - long mtime; - char *as; - char *ms; - struct utimbuf times; - - rpc_get (msock, RPC_STRING, &file, RPC_STRING, &as, RPC_STRING, &ms, - RPC_END); - sscanf (as, "%lx", &atime); - sscanf (ms, "%lx", &mtime); - if (verbose) - printf ("Got a = %s, m = %s, comp a = %ld, m = %ld\n", as, ms, - atime, mtime); - g_free (as); - g_free (ms); - times.actime = (time_t) atime; - times.modtime = (time_t) mtime; - status = utime (file, ×); - send_status (status, errno); - g_free (file); -} - -static void -do_quit (void) -{ - quit_server = 1; -} - -#ifdef HAVE_PAM - -struct user_pass { - const char *username; - const char *password; -}; - -static int -mc_pam_conversation (int messages, const struct pam_message **msg, - struct pam_response **resp, void *appdata_ptr) -{ - struct pam_response *r; - struct user_pass *up = appdata_ptr; - int status; - - r = (struct pam_response *) malloc (sizeof (struct pam_response) * - messages); - if (!r) - return PAM_CONV_ERR; - *resp = r; - - for (status = PAM_SUCCESS; messages--; msg++, r++) { - switch ((*msg)->msg_style) { - - case PAM_PROMPT_ECHO_ON: - r->resp = strdup (up->username); - r->resp_retcode = PAM_SUCCESS; - break; - - case PAM_PROMPT_ECHO_OFF: - r->resp = strdup (up->password); - r->resp_retcode = PAM_SUCCESS; - break; - - case PAM_ERROR_MSG: - r->resp = NULL; - r->resp_retcode = PAM_SUCCESS; - break; - - case PAM_TEXT_INFO: - r->resp = NULL; - r->resp_retcode = PAM_SUCCESS; - break; - } - } - return status; -} - -static struct pam_conv conv = { &mc_pam_conversation, NULL }; - - -/* Return 0 if authentication failed, 1 otherwise */ -static int -mc_pam_auth (const char *username, const char *password) -{ - pam_handle_t *pamh; - struct user_pass up; - int status; - - up.username = username; - up.password = password; - conv.appdata_ptr = &up; - - status = pam_start ("mcserv", username, &conv, &pamh); - if (status != PAM_SUCCESS) - goto failed_pam; - - status = pam_authenticate (pamh, 0); - if (status != PAM_SUCCESS) - goto failed_pam; - - status = pam_acct_mgmt (pamh, 0); - if (status != PAM_SUCCESS) - goto failed_pam; - - status = pam_setcred (pamh, PAM_ESTABLISH_CRED); - if (status != PAM_SUCCESS) - goto failed_pam; - - pam_end (pamh, status); - return 0; - - failed_pam: - pam_end (pamh, status); - return 1; -} - -#else /* !HAVE_PAM */ - -/* Keep reading until we find a \n */ -static int -next_line (int sock) -{ - char c; - - while (1) { - if (read (sock, &c, 1) <= 0) - return 0; - if (c == '\n') - return 1; - } -} - -static int -ftp_answer (int sock, const char *text) -{ - char answer[4]; - - next_line (sock); - socket_read_block (sock, answer, 3); - answer[3] = 0; - if (strcmp (answer, text) == 0) - return 1; - return 0; -} - -static int -send_string (int sock, const char *string) -{ - return socket_write_block (sock, string, strlen (string)); -} - -static int -do_ftp_auth (const char *username, const char *password) -{ - struct sockaddr_in local_address; - unsigned long inaddr; - int my_socket; - char answer[4]; - - memset ((char *) &local_address, 0, sizeof (local_address)); - - local_address.sin_family = AF_INET; - /* FIXME: extract the ftp port with the proper function */ - local_address.sin_port = htons (21); - - /* Convert localhost to usable format */ - inaddr = inet_addr ("127.0.0.1"); - if (inaddr != INADDR_NONE) - memcpy ((char *) &local_address.sin_addr, (char *) &inaddr, - sizeof (inaddr)); - - my_socket = socket (AF_INET, SOCK_STREAM, 0); - if (my_socket < 0) { - if (!isDaemon) - fprintf (stderr, "do_auth: can't create socket\n"); - return 0; - } - if (connect - (my_socket, (struct sockaddr *) &local_address, - sizeof (local_address)) < 0) { - fprintf (stderr, - "do_auth: can't connect to ftp daemon for authentication\n"); - close (my_socket); - return 0; - } - send_string (my_socket, "user "); - send_string (my_socket, username); - send_string (my_socket, "\r\n"); - if (!ftp_answer (my_socket, "331")) { - send_string (my_socket, "quit\r\n"); - close (my_socket); - return 0; - } - next_line (my_socket); /* Eat all the line */ - send_string (my_socket, "pass "); - send_string (my_socket, password); - send_string (my_socket, "\r\n"); - socket_read_block (my_socket, answer, 3); - answer[3] = 0; - send_string (my_socket, "\r\n"); - send_string (my_socket, "quit\r\n"); - close (my_socket); - if (strcmp (answer, "230") == 0) - return 1; - return 0; -} - -#ifdef HAVE_CRYPT -static int -do_classic_auth (const char *username, const char *password) -{ - int ret = 0; - const char *encr_pwd = NULL; - struct passwd *pw; -#ifdef HAVE_SHADOW - struct spwd *spw; -#endif - - pw = getpwnam (username); - if (pw == NULL) - return 0; - -#ifdef HAVE_SHADOW - setspent (); - - /* Password expiration is not checked! */ - spw = getspnam (username); - if (spw == NULL) - encr_pwd = "*"; - else - encr_pwd = spw->sp_pwdp; - - endspent (); -#else - encr_pwd = pw->pw_passwd; -#endif - - if (strcmp (crypt (password, encr_pwd), encr_pwd) == 0) - ret = 1; - - endpwent (); - return ret; -} -#endif /* HAVE_CRYPT */ -#endif /* !HAVE_PAM */ - -/* Try to authenticate the user based on: - - PAM if the system has it, else it checks: - - pwdauth if the system supports it. - - conventional auth (check salt on /etc/passwd, crypt, and compare - - try to contact the local ftp server and login (if -f flag used) -*/ -static int -do_auth (const char *username, const char *password) -{ - int auth = 0; - struct passwd *this; - - if (strcmp (username, "anonymous") == 0) - username = "ftp"; - -#ifdef HAVE_PAM - if (mc_pam_auth (username, password) == 0) - auth = 1; -#else /* if there is no pam */ -#ifdef HAVE_PWDAUTH - if (pwdauth (username, password) == 0) - auth = 1; - else -#endif -#ifdef HAVE_CRYPT - if (do_classic_auth (username, password)) - auth = 1; - else -#endif - if (ftp) - auth = do_ftp_auth (username, password); -#endif /* not pam */ - - if (!auth) - return 0; - - this = getpwnam (username); - if (this == 0) - return 0; - - if (chdir (this->pw_dir) == -1) - return 0; - - if (this->pw_dir[strlen (this->pw_dir) - 1] == '/') - home_dir = strdup (this->pw_dir); - else { - char *new_home_dir = malloc (strlen (this->pw_dir) + 2); - if (new_home_dir) { - strcpy (new_home_dir, this->pw_dir); - strcat (new_home_dir, "/"); - home_dir = new_home_dir; - } else - home_dir = "/"; - } - - - if (setgid (this->pw_gid) == -1) - return 0; - -#ifdef HAVE_INITGROUPS -#ifdef NGROUPS_MAX - if (NGROUPS_MAX > 1 && initgroups (this->pw_name, this->pw_gid)) - return 0; -#endif -#endif - - if (setuid (this->pw_uid)) - return 0; - - /* If the setuid call failed, then deny access */ - /* This should fix the problem on those machines with strange setups */ - if (getuid () != this->pw_uid) - return 0; - - if ( (strcmp(username, "ftp") == 0) && (chroot(this->pw_dir) != 0) ) { - error(0, errno, strerror(errno)); - return 0; - } - - endpwent (); - return auth; -} - -#if 0 -static int -do_rauth (int socket) -{ - struct sockaddr_in from; - struct hostent *hp; - - if (getpeername (0, (struct sockaddr *) &from, &fromlen) < 0) - return 0; - from.sin_port = ntohs ((unsigned short) from.sin_port); - - /* Strange, this should not happend */ - if (from.sin_family != AF_INET) - return 0; - - hp = gethostbyaddr ((char *) &fromp.sin_addr, sizeof (struct in_addr), - fromp.sin_family); - -} -#endif - -static int -do_rauth (int sock) -{ - sock = 0; /* prevent warning */ - return 0; -} - -static void -login_reply (int _logged_in) -{ - rpc_send (msock, RPC_INT, _logged_in ? MC_LOGINOK : MC_INVALID_PASS, - RPC_END); -} - -/* FIXME: Implement the anonymous login */ -static void -do_login (void) -{ - char *username; - char *password; - int result; - - rpc_get (msock, RPC_LIMITED_STRING, &up_dir, RPC_LIMITED_STRING, - &username, RPC_END); - if (verbose) - printf ("username: %s\n", username); - - if (r_auth) { - logged_in = do_rauth (msock); - if (logged_in) { - login_reply (logged_in); - return; - } - } - rpc_send (msock, RPC_INT, MC_NEED_PASSWORD, RPC_END); - rpc_get (msock, RPC_INT, &result, RPC_END); - if (result == MC_QUIT) - DO_QUIT_VOID (); - if (result != MC_PASS) { - if (verbose) - printf ("do_login: Unknown response: %d\n", result); - DO_QUIT_VOID (); - } - rpc_get (msock, RPC_LIMITED_STRING, &password, RPC_END); - logged_in = do_auth (username, password); - endpwent (); - login_reply (logged_in); -} - -/* }}} */ - -/* {{{ Server and dispatching functions */ - -/* This structure must be kept in synch with mcfs.h enums */ - -static const struct _command { - const char *command; - void (*callback) (void); -} commands[] = { - { - "open", do_open}, { - "close", do_close}, { - "read", do_read}, { - "write", do_write}, { - "opendir", do_opendir}, { - "readdir", do_readdir}, { - "closedir", do_closedir}, { - "stat ", do_stat}, { - "lstat ", do_lstat}, { - "fstat", do_fstat}, { - "chmod", do_chmod}, { - "chown", do_chown}, { - "readlink ", do_readlink}, { - "unlink", do_unlink}, { - "rename", do_rename}, { - "chdir ", do_chdir}, { - "lseek", do_lseek}, { - "rmdir", do_rmdir}, { - "symlink", do_symlink}, { - "mknod", do_mknod}, { - "mkdir", do_mkdir}, { - "link", do_link}, { - "gethome", do_gethome}, { - "getupdir", do_getupdir}, { - "login", do_login}, { - "quit", do_quit}, { -"utime", do_utime}}; - -static int ncommands = sizeof (commands) / sizeof (struct _command); - -static void -exec_command (int command) -{ - if (command < 0 || command >= ncommands - || commands[command].command == 0) { - fprintf (stderr, "Got unknown command: %d\n", command); - DO_QUIT_VOID (); - } - if (verbose) - printf ("Command: %s\n", commands[command].command); - (*commands[command].callback) (); -} - -static void -check_version (void) -{ - int version; - - rpc_get (msock, RPC_INT, &version, RPC_END); - if (version >= 1 && version <= RPC_PROGVER) - rpc_send (msock, RPC_INT, MC_VERSION_OK, RPC_END); - else - rpc_send (msock, RPC_INT, MC_VERSION_MISMATCH, RPC_END); - - clnt_version = version; -} - -/* This routine is called by rpc_get/rpc_send when the connection is closed */ -void -tcp_invalidate_socket (int sock) -{ - if (verbose) - printf ("Connection closed [socket %d]\n", sock); - DO_QUIT_VOID (); -} - -static void -server (int sock) -{ - int command; - - msock = sock; - quit_server = 0; - - check_version (); - do { - if (rpc_get (sock, RPC_INT, &command, RPC_END) - && (logged_in || command == MC_LOGIN)) - exec_command (command); - } while (!quit_server); -} - -/* }}} */ - -/* {{{ Net support code */ - -static const char * -get_client (int port) -{ - int sock, newsocket; - unsigned int clilen; - struct sockaddr_in client_address, server_address; - int yes = 1; - - sock = socket (AF_INET, SOCK_STREAM, 0); - if (sock < 0) - return "Cannot create socket"; - - /* Use this to debug: */ - if (setsockopt - (sock, SOL_SOCKET, SO_REUSEADDR, (char *) &yes, sizeof (yes)) < 0) - return "setsockopt failed"; - - memset ((char *) &server_address, 0, sizeof (server_address)); - server_address.sin_family = AF_INET; - server_address.sin_addr.s_addr = htonl (INADDR_ANY); - server_address.sin_port = htons (port); - - if (bind - (sock, (struct sockaddr *) &server_address, - sizeof (server_address)) < 0) - return "Cannot bind"; - - listen (sock, 5); - - for (;;) { - int child; - - clilen = sizeof (client_address); - newsocket = - accept (sock, (struct sockaddr *) &client_address, &clilen); - - child = fork (); - if (isDaemon != 0 && child != 0) { - int status; - - close (newsocket); - waitpid (child, &status, 0); - continue; - } - - if (isDaemon && fork ()) - exit (0); - - server (newsocket); - close (newsocket); - return 0; - } -} - -#ifdef HAVE_PMAP_SET -static void -signal_int_handler (int sig) -{ - (void) sig; - - pmap_unset (RPC_PROGNUM, RPC_PROGVER); -} -#endif - -#ifndef IPPORT_RESERVED -#define IPPORT_RESERVED 1024 -#endif - -static int -get_port_number (void) -{ - int port = 0; - -#ifdef HAVE_RRESVPORT - int start_port = IPPORT_RESERVED; - - port = rresvport (&start_port); - if (port == -1) { - if (geteuid () == 0) { - fprintf (stderr, - "Cannot bind the server on a reserved port\n"); - DO_QUIT_NONVOID (-1); - } - port = 0; - } -#endif - if (port) - return port; - - port = mcserver_port; - - return port; -} - -static void -register_port (int port, int abort_if_fail) -{ -#ifdef HAVE_PMAP_SET - /* Register our service with the portmapper */ - /* protocol: pmap_set (prognum, versnum, protocol, portp) */ - - if (pmap_set (RPC_PROGNUM, RPC_PROGVER, IPPROTO_TCP, port)) - signal (SIGINT, signal_int_handler); - else { - fprintf (stderr, "Cannot register service with portmapper\n"); - if (abort_if_fail) - exit (EXIT_FAILURE); - } -#else - (void) port; - if (abort_if_fail) { - fprintf (stderr, - "This system lacks port registration, try using the -p\n" - "flag to force installation at a given port"); - } -#endif -} - -/* }}} */ - -int -main (int argc, char *argv[]) -{ - const char *result; - int c; - - while ((c = getopt (argc, argv, "fdiqp:v")) != -1) { - switch (c) { - case 'd': - isDaemon = 1; - verbose = 0; - break; - - case 'v': - verbose = 1; - break; - - case 'f': - ftp = 1; - break; - - case 'q': - verbose = 0; - break; - - case 'p': - portnum = atoi (optarg); - break; - - case 'i': - inetd_started = 1; - break; - - case 'r': - r_auth = 1; - break; - - default: - fprintf (stderr, - "Usage is: mcserv [options] [-p portnum]\n\n" - "options are:\n" "-d become a daemon (sets -q)\n" - "-q quiet mode\n" - /* "-r use rhost based authentication\n" */ -#ifndef HAVE_PAM - "-f force ftp authentication\n" -#endif - "-v verbose mode\n" - "-p to specify a port number to listen\n"); - exit (0); - - } - } - - if (isDaemon && fork ()) - exit (0); - - if (portnum == 0) - portnum = get_port_number (); - - if (portnum != -1) { - register_port (portnum, 0); - if (verbose) - printf ("Using port %d\n", portnum); - - result = get_client (portnum); - if (result != NULL) - perror (result); -#ifdef HAVE_PMAP_SET - if (isDaemon == 0) - pmap_unset (RPC_PROGNUM, RPC_PROGVER); -#endif - } - exit (return_code); -} diff --git a/lib/vfs/mc-vfs/vfs.c b/lib/vfs/mc-vfs/vfs.c index 608f36356..713152abe 100644 --- a/lib/vfs/mc-vfs/vfs.c +++ b/lib/vfs/mc-vfs/vfs.c @@ -66,7 +66,6 @@ # include "netutil.h" #endif #include "ftpfs.h" -#include "mcfs.h" #include "smbfs.h" #include "local.h" @@ -1349,9 +1348,6 @@ vfs_init (void) #ifdef ENABLE_VFS_SMB init_smbfs (); #endif /* ENABLE_VFS_SMB */ -#ifdef ENABLE_VFS_MCFS - init_mcfs (); -#endif /* ENABLE_VFS_MCFS */ #endif /* USE_NETCODE */ vfs_setup_wd (); diff --git a/m4.include/mc-mcserver.m4 b/m4.include/mc-mcserver.m4 deleted file mode 100644 index 6fd02bc3d..000000000 --- a/m4.include/mc-mcserver.m4 +++ /dev/null @@ -1,69 +0,0 @@ -dnl MC_MCSERVER_CHECKS -dnl Check how mcserver should check passwords. -dnl Possible methods are PAM, pwdauth and crypt. -dnl The later works with both /etc/shadow and /etc/passwd. -dnl If PAM is found, other methods are not checked. - -AC_DEFUN([MC_MCSERVER_CHECKS], [ - - dnl - dnl mcfs server support - dnl - AC_ARG_ENABLE([mcserver], - [ --enable-mcserver Support mc-specific networking file system server [[no]]], - [enable_mcserver="$enableval"] - ) - - if test x"$enable_mcserver" = "xyes"; then - AC_DEFINE(ENABLE_MCSERVER, 1, [Define to enable mc-specific networking file system server]) - AC_REQUIRE_SOCKET - AC_CHECK_RPC - use_net_code=true - - dnl Check if PAM can be used for mcserv - AC_CHECK_LIB(dl, dlopen, [LIB_DL="-ldl"]) - AC_CHECK_LIB(pam, pam_start, [ - AC_DEFINE(HAVE_PAM, 1, - [Define if PAM (Pluggable Authentication Modules) is available]) - MCSERVLIBS="-lpam $LIB_DL" - mcserv_pam=yes], [], [$LIB_DL]) - - dnl Check for crypt() - needed for both /etc/shadow and /etc/passwd. - if test x"$mcserv_pam" = x; then - - dnl Check for pwdauth() - used on SunOS. - AC_CHECK_FUNCS([pwdauth]) - - dnl Check for crypt() - AC_CHECK_HEADERS([crypt.h], [crypt_header=yes]) - if test -n "$crypt_header"; then - save_LIBS="$LIBS" - LIBS= - AC_SEARCH_LIBS(crypt, [crypt crypt_i], [mcserv_auth=crypt]) - MCSERVLIBS="$LIBS" - LIBS="$save_LIBS" - if test -n "$mcserv_auth"; then - AC_DEFINE(HAVE_CRYPT, 1, - [Define to use crypt function in mcserv]) - - dnl Check for shadow passwords - AC_CHECK_HEADERS([shadow.h shadow/shadow.h], - [shadow_header=yes; break]) - if test -n "$shadow_header"; then - save_LIBS="$LIBS" - LIBS="$MCSERVLIBS" - AC_SEARCH_LIBS(getspnam, [shadow], [mcserv_auth=shadow]) - MCSERVLIBS="$LIBS" - LIBS="$save_LIBS" - if test -n "$mcserv_auth"; then - AC_DEFINE(HAVE_SHADOW, 1, - [Define to use shadow passwords for mcserv]) - fi - fi - fi - fi - fi - fi - AM_CONDITIONAL(ENABLE_MCSERVER, [test x"$enable_mcserver" = "xyes"]) - AC_SUBST(MCSERVLIBS) -]) diff --git a/m4.include/mc-vfs.m4 b/m4.include/mc-vfs.m4 index d8f4e8577..9d344c5fb 100644 --- a/m4.include/mc-vfs.m4 +++ b/m4.include/mc-vfs.m4 @@ -16,7 +16,6 @@ m4_include([m4.include/vfs/mc-vfs-fish.m4]) m4_include([m4.include/vfs/mc-vfs-undelfs.m4]) m4_include([m4.include/vfs/mc-vfs-tarfs.m4]) m4_include([m4.include/vfs/mc-vfs-cpiofs.m4]) -m4_include([m4.include/vfs/mc-vfs-mcfs.m4]) m4_include([m4.include/vfs/mc-vfs-samba.m4]) m4_include([m4.include/vfs/mc-mvfs.m4]) @@ -75,7 +74,6 @@ AC_DEFUN([AC_MC_VFS_CHECKS],[ AC_MC_VFS_EXTFS AC_MC_VFS_SFS AC_MC_VFS_UNDELFS - AC_MC_VFS_MCFS AC_MC_VFS_SAMBA MC_WITH_VFS @@ -91,7 +89,5 @@ AC_DEFUN([AC_MC_VFS_CHECKS],[ AM_CONDITIONAL(ENABLE_VFS_UNDELFS, [false]) fi - MC_MCSERVER_CHECKS - AM_CONDITIONAL(ENABLE_VFS, [test x"$enable_vfs" = x"yes"]) ]) diff --git a/m4.include/vfs/mc-vfs-mcfs.m4 b/m4.include/vfs/mc-vfs-mcfs.m4 deleted file mode 100644 index 7fc6f82a5..000000000 --- a/m4.include/vfs/mc-vfs-mcfs.m4 +++ /dev/null @@ -1,17 +0,0 @@ -AC_DEFUN([AC_MC_VFS_MCFS_SET], -[ - AC_REQUIRE_SOCKET - AC_CHECK_RPC - AC_DEFINE(ENABLE_VFS_MCFS, 1, [Define to enable mc-specific networking file system]) - AC_MC_VFS_ADDNAME([mcfs]) - use_net_code=true -]) - -AC_DEFUN([AC_MC_VFS_MCFS], -[ - AC_ARG_ENABLE([vfs-mcfs], - [ --enable-vfs-mcfs Enable Support MCFS (mc's network filesystem)]) - if test x"$enable_vfs_mcfs" = x"yes" ; then - AC_MC_VFS_MCFS_SET - fi -]) diff --git a/maint/mc-test b/maint/mc-test index d3fea71a0..a8eaeece2 100755 --- a/maint/mc-test +++ b/maint/mc-test @@ -48,7 +48,7 @@ mc_cflags="" mc_ldflags="" -mc_tests="plain glib12 charset no_charset vfs no_vfs mcfs no_mcfs samba "\ +mc_tests="plain glib12 charset no_charset vfs no_vfs samba "\ "no_samba ext2undel no_ext2undel slang ncurses maintainer "\ "no_maintainer i18n no_i18n no_features all_features" @@ -151,12 +151,12 @@ renice ${mc_nice_value} $$ 1>/dev/null 2>&1 || true configure_args_enable_all="--enable-largefile --enable-nls "\ "--enable-netcode --enable-background --enable-charset "\ "--with-mmap --with-included-gettext --with-x "\ -"--with-vfs --with-mcfs --with-samba --with-ext2undel "\ +"--with-vfs --with-samba --with-ext2undel "\ "--with-gpm-mouse --with-subshell --with-edit" configure_args_disable_all="--disable-largefile --disable-nls "\ "--disable-netcode --disable-background --disable-charset "\ "--without-mmap --without-included-gettext --without-x "\ -"--without-vfs --without-mcfs --without-samba --without-ext2undel "\ +"--without-vfs --without-samba --without-ext2undel "\ "--without-gpm-mouse --without-subshell --without-edit" errors=0 @@ -401,18 +401,6 @@ test_no_vfs() { confbuild } -test_mcfs() { - testname="mcfs" - configure_args="--with-mcfs" - confbuild -} - -test_no_mcfs() { - testname="no_mcfs" - configure_args="--without-mcfs" - confbuild -} - test_samba() { testname="samba" configure_args="--with-samba" diff --git a/maint/mc-test-example.conf b/maint/mc-test-example.conf index 6657f6740..c5458ac8d 100644 --- a/maint/mc-test-example.conf +++ b/maint/mc-test-example.conf @@ -47,7 +47,7 @@ #mc_ldflags="" # The list of tests that will be run. -#mc_tests="plain glib12 charset no_charset vfs no_vfs mcfs no_mcfs samba "\ +#mc_tests="plain glib12 charset no_charset vfs no_vfs samba "\ #"no_samba ext2undel no_ext2undel slang ncurses maintainer "\ #"no_maintainer i18n no_i18n no_features all_features" diff --git a/maint/mctest b/maint/mctest index a2e303091..e9ea8c5a3 100755 --- a/maint/mctest +++ b/maint/mctest @@ -41,7 +41,7 @@ distcheck 1 echo "Checking the configuration with maximal code coverage" distcheck 2 enable_charset=yes with_samba=yes \ - with_mcfs=yes with_included_gettext=yes with_glib12=yes + with_included_gettext=yes with_glib12=yes echo "Checking the configuration with minimal code coverage" distcheck 3 enable_largefile=no enable_nls=no with_vfs=no \ diff --git a/misc/mc.ext.in b/misc/mc.ext.in index fa601122b..88d8ab426 100644 --- a/misc/mc.ext.in +++ b/misc/mc.ext.in @@ -42,7 +42,7 @@ # %% -> % character # %p -> name of the current file (without path, but pwd is its path) # %f -> name of the current file. Unlike %p, if file is located on a -# non-local virtual filesystem, i.e. either tarfs, mcfs or ftpfs, +# non-local virtual filesystem, i.e. either tarfs or ftpfs, # then the file will be temporarily copied into a local directory # and %f will be the full path to this local temporal file. # If you don't want to get a local copy and want to get the diff --git a/src/cmd.c b/src/cmd.c index 698717437..be9a6ec23 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -1259,15 +1259,6 @@ nice_cd (const char *text, const char *xtext, const char *help, static const char *machine_str = N_("Enter machine name (F1 for details):"); -#ifdef ENABLE_VFS_MCFS -void -netlink_cmd (void) -{ - nice_cd (_("Link to a remote machine"), _(machine_str), - "[Network File System]", ":netlink_cmd: Link to a remote ", "/#mc:", 1); -} -#endif /* ENABLE_VFS_MCFS */ - void ftplink_cmd (void) { diff --git a/src/cmd.h b/src/cmd.h index 44b8f81c2..253918da0 100644 --- a/src/cmd.h +++ b/src/cmd.h @@ -17,7 +17,6 @@ typedef enum LINK_SYMLINK_RELATIVE } link_type_t; -void netlink_cmd (void); void ftplink_cmd (void); void fishlink_cmd (void); void smblink_cmd (void); diff --git a/src/cmddef.h b/src/cmddef.h index 7d6321ef1..8dd186233 100644 --- a/src/cmddef.h +++ b/src/cmddef.h @@ -354,7 +354,6 @@ #define CK_ListmodeCmd 7042 #define CK_MenuLastSelectedCmd 7044 #define CK_MkdirCmd 7045 -#define CK_NetlinkCmd 7046 #define CK_QuickCdCmd 7047 #define CK_QuickChdirCmd 7048 #define CK_QuickViewCmd 7049 diff --git a/src/keybind.c b/src/keybind.c index e801e5246..382de3cb8 100644 --- a/src/keybind.c +++ b/src/keybind.c @@ -367,9 +367,6 @@ static name_keymap_t command_names[] = { { "CmdListmodeCmd", CK_ListmodeCmd }. #endif { "CmdMkdir", CK_MkdirCmd }, -#if defined (USE_NETCODE) && defined (ENABLE_VFS_MCFS) - { "CmdNetlink", CK_NetlinkCmd }, -#endif { "CmdPanelOptions", CK_PanelOptionsBox }, { "CmdQuickCd", CK_QuickCdCmd }, { "CmdQuickChdir", CK_QuickChdirCmd }, diff --git a/src/main.c b/src/main.c index 53c508b1a..4deeecdbb 100644 --- a/src/main.c +++ b/src/main.c @@ -683,9 +683,6 @@ create_panel_menu (void) #endif #ifdef USE_NETCODE entries = g_list_append (entries, menu_separator_create ()); -#ifdef ENABLE_VFS_MCFS - entries = g_list_append (entries, menu_entry_create (_("&Network link..."), CK_NetlinkCmd)); -#endif entries = g_list_append (entries, menu_entry_create (_("FT&P link..."), CK_FtplinkCmd)); entries = g_list_append (entries, menu_entry_create (_("S&hell link..."), CK_FishlinkCmd)); #ifdef ENABLE_VFS_SMB @@ -1320,11 +1317,6 @@ midnight_execute_cmd (Widget * sender, unsigned long command) case CK_MkdirCmd: mkdir_cmd (); break; -#if defined (USE_NETCODE) && defined (ENABLE_VFS_MCFS) - case CK_NetlinkCmd: - netlink_cmd (); - break; -#endif case CK_PanelOptionsBox: panel_options_box (); break; diff --git a/src/textconf.c b/src/textconf.c index b9344aa86..f27bcedcf 100644 --- a/src/textconf.c +++ b/src/textconf.c @@ -39,9 +39,6 @@ static const char *const vfs_supported[] = { #ifdef USE_NETCODE "ftpfs", "fish", -# ifdef ENABLE_VFS_MCFS - "mcfs", -# endif # ifdef ENABLE_VFS_SMB "smbfs", # endif /* ENABLE_VFS_SMB */