RMTGETCONN(3L)

πŸ“¦
version 2022.10.16 Β· 2 versions
, in opensuse-leap 16.0

πŸ’– NAME πŸ’–

omg hey bestie 🫢 welcome to RMTGETCONN(3L), aka one of the librmt girlies from SchilyΒ΄s LIBRARY FUNCTIONS. This page covers rmtinit, rmtdebug, rmthostname, rmtfilename, and rmtgetconn β€” the little squad that handles initiate a connection to a remote tape server (-lrmt). periodt. πŸ’…

✨ SYNOPSIS ✨

okay bestie, here are the exact signatures β€” do not freestyle these, fr fr:

       #include <schily/librmt.h>

       void rmtinit(errmsgn, eexit)
            int     (*errmsgn) (int, const char *, ...);
            void    (*eexit)   (int);

       int rmtdebug(dlevel)
            int     dlevel;

       const char *rmtrmt(rmtname)
            const char    *rmtname;

       const char *rmtrsh(rshname)
            const char    *rshname;

       char *rmtfilename(name)
            char    *name;

       char *rmthostname(hostname, hnsize, rmtspec)
            char    *hostname;
            int     hnsize;
            char    *rmtspec;

       int rmtgetconn(host, trsize, excode)
            char    *host;
            int     trsize;
            int     excode;

πŸ’– DESCRIPTION πŸ’–

okay so the whole vibe of this section is: set stuff up, then connect. Here's every function, no skips:

  • rmtinit() β€” optional lil setup moment. It lets you set up a function for error printing and a function to be called to exit the program. If rmtinit(3) isn't called, or any of the function pointers is NULL, the appropriate default function is used instead. Your supplied error printing function needs to implement the same interface as errmsgno(3), and your supplied exit function needs to implement the same interface as exit(3).
  • rmtdebug() β€” lets you set the debug level for the library code. Default debug level is 0, and it does not print debug messages.
  • rmtrmt() β€” lets you set up a different default path to the remote rmt server program. Otherwise the default is /etc/rmt. The RMT environment still overwrites the default set up by rmtrmt(3).
  • rmtrsh() β€” lets you set up a different remote login program to the remote rmt server program. Otherwise the default is to use rcmd(3). The RSH environment still overwrites the default set up by rmtrsh(3).
  • rmtfilename() β€” you give it a filename that may be either in remote file syntax (hostname:filename or user@hostname:filename) or specified as a hierarchical file path. If the argument turns out to be in remote file syntax, a pointer to the filename part is returned.
  • rmthostname() β€” copies the user/host part of rmtspec, which should be in remote file syntax. First argument is a character array that should be large enough to hold the user/host part of rmtspec. Second argument is the size of the character array. Third argument is a string in remote file syntax.
  • rmtgetconn() β€” establishes a connection to the remote tape server process. First parameter is the usr/host part of a string in remote file syntax and should be created via rmthostname(3). Second parameter is the expected maximum transfer size. It is used to set up kernel buffering via setsockopt(3) to increase performance. Third parameter is an alternate exit code to be used instead of the library default if rmtgetconn(3) decides to call exit(3). This allows commands like ufsdump to use the documented exit codes for startup errors.

πŸ’œ RETURNS πŸ’œ

okay now the receipts β€” what each one gives back:

  • rmtdebug() β€” returns the old debug level.
  • rmtrmt() β€” returns the old default remote rmt server program path, or NULL in case the default was not overwritten.
  • rmtrsh() β€” returns the old default rmt remote login program, or NULL in case the default was not overwritten.
  • rmtfilename() β€” returns the filename part of the argument string, or NULL in case the argument turns out to be not in remote file syntax.
  • rmthostname() β€” returns a pointer to the first argument, or NULL in case the rmtspec argument turns out to be not in remote file syntax.
  • rmtgetconn() β€” returns a file descriptor suitable to be used as first argument for functions like rmtopen(3) or rmtwrite(3). If rmtgetconn(3) fails to set up a connection, -1 is returned. If rmtgetconn(3) is unable to find the port number for shell/tcp, the current uid has no entry in the passwd file, or the user name includes illegal characters, exit() is called. If you do not like rmtgetconn(3) to exit in this case, call rmtinit(3) before and install a non exiting function as exit(3) handler; rmtgetconn(3) then will return -2 after this function did return.

🌸 EXAMPLES 🌸

bestie, here's the example exactly as the page gives it β€” yes, including the little quirks, don't @ me:

       int  remfd;
       char *remfn;
       char host[256];
       int  iosize = 10240;     /* socket send/receive size to set up */

       if ((remfn = rmtfilename(filename)) != NULL) {
            rmthostname(host, sizeof (host), filename);

            if ((remfd = rmtgetconn(host, iosize, 0)) < 0)
                 comerrno(EX_BAD, "Cannot get connection to '%s'.\n",
                      /* errno not valid !! */      host);
       }

       if (rmtopen(remfd, remfn, mode) < 0)
            comerr("Cannot open '%s'.\n", remfn);

       if (rmtread(remfd, buf, sizeof(buf) < 0)
            comerr("Read error on '%s'.\n", remfn);

       rmtclose(remfd);

πŸ¦‹ ENVIRONMENT πŸ¦‹

  • RSH β€” if the RSH environment is present, the remote connection will not be created via rcmd(3) but by calling the program pointed to by RSH. Use e.g. RSH=/usr/bin/ssh to create a secure shell connection. If the environment RSH is empty, then the default rcmd(3) is used even in case rmtrsh(3) has been called.
  • RMT β€” if the RMT environment is present, the remote tape server will not be the program /etc/rmt but the program pointed to by RMT. If the environment RMT is empty, then the default /etc/rmt is used even in case rmtrmt(3) has been called. Note that the remote tape server program name will be ignored if you log in using an account that has been created with a remote tape server program as login shell.

πŸ‘‘ SEE ALSO πŸ‘‘

okay bestie, go read these next (iykyk):

rmt(1), rsh(1), ssh(1), rcmd(3), rmtinit(3), rmtdebug(3), rmtrmt(3), rmtrsh(3), rmthostname(3), rmtfilename(3), rmtgetconn(3), rmtopen(3), rmtioctl(3), rmtclose(3), rmtread(3), rmtwrite(3), rmtseek(3), rmtxstatus(3), rmtstatus(3), _mtg2rmtg(3), _rmtg2mtg(3), errmsgno(3)

πŸ’€ BUGS πŸ’€

For now (late 2002), we know that the following programs are broken and do not implement signal handling correctly:

  • rsh on SunOS-5.0...SunOS-5.9
  • ssh from ssh.com
  • ssh from openssh.org

Sun already did accept a bug report for rsh(1). Openssh.org accepted a bug for their implementation of ssh(1).

If you use rmtgetconn(3) to create a remote connection via an unfixed rsh(1) or ssh(1), be prepared that terminal generated signals may interrupt the remote connection.

Mail other bugs and suggestions to schilytools@mlists.in-berlin.de or open a ticket at https://codeberg.org/schilytools/schilytools/issues.

The mailing list archive may be found at:

https://mlists.in-berlin.de/mailman/listinfo/schilytools-mlists.in-berlin.de.

πŸŽ€ AUTHORS πŸŽ€

librmt has been written in 1990 by Joerg Schilling. In 1995, support for RMT VERSION 1 has been added. librmt is now maintained by the schilytools project authors.

🌈 SOURCE DOWNLOAD 🌈

The source code for librmt is included in the schilytools project and may be retrieved from the schilytools project at Codeberg at

https://codeberg.org/schilytools/schilytools.

The download directory is

https://codeberg.org/schilytools/schilytools/releases.


okay that's the whole page, bestie πŸ’– β€” RMTGETCONN(3L) Β· SchilyΒ΄s LIBRARY FUNCTIONS Β· 2022/08/21 Β· Joerg Schilling. go forth and connect responsibly ✨🫢

πŸ“¦ where this page comes from