Changeset 2224


Ignore:
Timestamp:
Jun 17, 2009, 4:43:35 AM (10 years ago)
Author:
bruno
Message:
  • Add support of user for NFS write and fixes #316
Location:
branches/2.2.9
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.9/mondo-doc/mondoarchive.8

    r2062 r2224  
    122122.I mount
    123123is the remote mount-point, e.g. '192.168.1.3:/home/nfs'
    124 for my file server. Please mount it before backing up/verifying.
     124for my file server. If not mounted, mondoarchive will do it for you. So nice ;-)
     125If your NFS server only accept write from a backup user, you may specify it with the syntax:
     126.B user@machine:/mount/path
     127and mondoarchive will try to do its best to support it using sudo.
    125128
    126129.TP
  • branches/2.2.9/mondo/src/common/libmondo-cli.c

    r2223 r2224  
    988988            strncpy(bkpinfo->nfs_remote_dir, "/", MAX_STR_LEN);
    989989        }
     990        /* test if we specified a user for the NFS dialog */
     991        p = strchr(bkpinfo->nfs_mount, '@');
     992        if (p != NULL) {
     993            /* User found. Store the 2 values */
     994            p++;
     995            /* new NFS mount */
     996            strcpy(tmp,p);
     997            p--;
     998            *p = '\0';
     999            strcpy(bkpinfo->nfs_user,bkpinfo->nfs_mount);
     1000            strcpy(bkpinfo->nfs_mount,tmp);
     1001        }
    9901002        sprintf(tmp, "mount | grep -E \"^%s[/]* .*\" | cut -d' ' -f3",
    9911003                bkpinfo->nfs_mount);
     
    11361148    {
    11371149//      strncpy(psz, list_of_NFS_devices_and_mounts(), MAX_STR_LEN);
    1138         asprintf(&psz, "%s", list_of_NFS_mounts_only());
     1150        mr_asprintf(&psz, "%s", list_of_NFS_mounts_only());
    11391151        if (bkpinfo->exclude_paths[0]) {
    11401152            strncat(bkpinfo->exclude_paths, " ", 4*MAX_STR_LEN);
     
    12281240    if ((flag_set['n']) && (! bkpinfo->restore_data)) {
    12291241        mr_asprintf(&tmp1,"%s/%s/.dummy.txt", bkpinfo->isodir,bkpinfo->nfs_remote_dir);
    1230         sprintf(tmp, "echo hi > %s", tmp1);
     1242        if (bkpinfo->nfs_user) {
     1243            sprintf(tmp, "sudo -u %s echo hi > %s", bkpinfo->nfs_user, tmp1);
     1244        } else {
     1245            sprintf(tmp, "echo hi > %s", tmp1);
     1246        }
    12311247        if (run_program_and_log_output(tmp, 2)) {
    12321248            retval++;
  • branches/2.2.9/mondo/src/common/libmondo-devices.c

    r2220 r2224  
    12831283    make_hole_for_dir(mountpoint);
    12841284
    1285 #ifndef __FreeBSD__
     1285#ifdef __FreeBSD__
    12861286    char *dev = NULL;
     1287#else
    12871288    char *options = NULL;
    12881289    mr_asprintf(&options, "ro");
     
    14691470{
    14701471    char *tmp = NULL;
    1471     char *tmp1 = NULL;
    14721472    char *sz_size;
    14731473    char *command;
     
    20532053    log_it("isodir = %s", bkpinfo->isodir);
    20542054    log_it("nfs_mount = '%s'", bkpinfo->nfs_mount);
     2055    if (bkpinfo->nfs_user != NULL) {
     2056        log_it("nfs_user = '%s'", bkpinfo->nfs_user);
     2057    }
    20552058#endif
    20562059
     
    21012104    static char result_sz[1024];
    21022105
    2103     mr_asprintf(exclude_these_directories,"%s",list_of_NFS_mounts_only());
    2104     mr_asprintf(exclude_these_devices,"%s",
     2106    mr_asprintf(&exclude_these_directories,"%s",list_of_NFS_mounts_only());
     2107    mr_asprintf(&exclude_these_devices,"%s",
    21052108           call_program_and_get_last_line_of_output
    21062109           ("tr -s '\t' ' ' < /etc/fstab | grep -E '( (coda|ncpfs|nfs|nfs4|smbfs|cifs|afs|gfs|ocfs|ocfs2|mvfs|nsspool|nsvol) )' | cut -d' ' -f1 | tr -s '\n' ' ' | awk '{print $0;}'"));
    2107     snprintf(result_sz, "%s %s", exclude_these_directories,
    2108             exclude_these_devices, 1023);
     2110    snprintf(result_sz, 1023, "%s %s", exclude_these_directories, exclude_these_devices);
    21092111    mr_free(exclude_these_devices);
    21102112    mr_free(exclude_these_directories);
     
    21292131           call_program_and_get_last_line_of_output
    21302132           ("mount -t coda,ncpfs,nfs,nfs4,smbfs,cifs,afs,gfs,ocfs,ocfs2,mvfs,nsspool,nssvol | tr -s '\t' ' ' | cut -d' ' -f3 | tr -s '\n' ' ' | awk '{print $0;}'"));
    2131     snprintf(result_sz, "%s", exclude_these_directories, 511);
     2133    snprintf(result_sz, 511, "%s", exclude_these_directories);
    21322134    mr_free(exclude_these_directories);
    21332135    return (result_sz);
  • branches/2.2.9/mondo/src/common/libmondo-fork.c

    r2178 r2224  
    77
    88#include "my-stuff.h"
     9#include "mr_mem.h"
    910#include "mondostructures.h"
    1011#include "libmondo-fork.h"
     
    103104        *old_stderr, *cd_number_str;
    104105    char *p;
     106    char *tmp1 = NULL;
    105107
    106108/*@***********   End Variables ***************************************/
     
    131133    old_stderr[0] = '\0';
    132134
     135    if (bkpinfo->nfs_user != NULL) {
     136        mr_asprintf(&tmp1, "sudo -u %s %s", bkpinfo->nfs_user, basic_call);
     137    } else {
     138        mr_asprintf(&tmp1, "%s", basic_call);
     139    }
     140
    133141    sprintf(cd_number_str, "%d", cd_no);
    134     resolve_naff_tokens(midway_call, basic_call, isofile, "_ISO_");
     142    resolve_naff_tokens(midway_call, tmp1, isofile, "_ISO_");
    135143    resolve_naff_tokens(tmp, midway_call, cd_number_str, "_CD#_");
    136144    resolve_naff_tokens(ultimate_call, tmp, MONDO_LOGFILE, "_ERR_");
    137     log_msg(4, "basic call = '%s'", basic_call);
     145    log_msg(4, "basic call = '%s'", tmp1);
    138146    log_msg(4, "midway_call = '%s'", midway_call);
    139147    log_msg(4, "tmp = '%s'", tmp);
     
    169177        }
    170178        if (retval) {
    171             log_msg(2, "Basic call '%s' returned an error.", basic_call);
     179            log_msg(2, "Basic call '%s' returned an error.", tmp1);
    172180            popup_and_OK("Press ENTER to continue.");
    173181            popup_and_OK
     
    184192    }
    185193
     194    mr_free(tmp1);
    186195    paranoid_free(midway_call);
    187196    paranoid_free(ultimate_call);
  • branches/2.2.9/mondo/src/common/libmondo-tools.c

    r2211 r2224  
    857857    bkpinfo->kernel_path[0] = '\0';
    858858    bkpinfo->nfs_mount[0] = '\0';
     859    bkpinfo->nfs_user[0] = '\0';
    859860    bkpinfo->nfs_remote_dir[0] = '\0';
    860861    bkpinfo->postnuke_tarball[0] = '\0';
  • branches/2.2.9/mondo/src/common/mondostructures.h

    r2188 r2224  
    570570   */
    571571    char nfs_remote_dir[MAX_STR_LEN];
     572
     573  /**
     574   * The potential user to use for NFS backup
     575   */
     576    char nfs_user[MAX_STR_LEN/4];
    572577
    573578  /**
Note: See TracChangeset for help on using the changeset viewer.