Annotation of researchv10no/ipc/libipc/ipcexec.c, revision 1.1.1.1

1.1       root        1: #include <ipc.h>
                      2: #include "defs.h"
                      3: 
                      4: /*
                      5:  *  Perform a remote execution of a command.
                      6:  */
                      7: ipcexec(name, param, cmd)
                      8:        char *name;
                      9:        char *param;
                     10:        char *cmd;
                     11: {
                     12:        return _ipcexec(name, "dk", "exec", param, cmd);
                     13: }
                     14: 
                     15: ipcmesgexec(name, param, cmd)
                     16:        char *name;
                     17:        char *param;
                     18:        char *cmd;
                     19: {
                     20:        return _ipcexec(name, "dk", "mesgexec", param, cmd);
                     21: }
                     22: 
                     23: _ipcexec(name, def, service, param, cmd)
                     24:        char *name;
                     25:        char *service;
                     26:        char *def;
                     27:        char *param;
                     28:        char *cmd;
                     29: {
                     30:        int fd, len;
                     31: 
                     32:        fd = ipcopen(ipcpath(name, def, service), param);
                     33:        if (fd<0)
                     34:                return -1;
                     35:        if (ipclogin(fd)<0) {
                     36:                close(fd);
                     37:                return -1;
                     38:        }
                     39:        len = strlen(cmd)+1;
                     40:        if (write(fd, cmd, len)!=len) {
                     41:                errstr = "write error";
                     42:                close(fd);
                     43:                return -1;
                     44:        }
                     45:        return fd;
                     46: }
                     47: 
                     48: ipcrexec(name, param, cmd)
                     49:        char *name;
                     50:        char *param;
                     51:        char *cmd;
                     52: {
                     53:        int fd, n;
                     54:        char nparam[512];
                     55: 
                     56:        strcpy(nparam, "bsdauth ");
                     57:        n = strlen(nparam);
                     58:        strncat(nparam+n, param, sizeof(nparam)-n-1);
                     59:        fd = ipcopen(ipcpath(name, "tcp", "shell"), nparam);
                     60:        if (fd<0)
                     61:                return -1;
                     62:        if (ipcrogin(fd, cmd)<0) {
                     63:                close(fd);
                     64:                return -1;
                     65:        }
                     66:        return fd;
                     67: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.