Exemple #1
0
def refreshSambaTmpPasswdFile(pwd):
        a = []

        a.append(pwd)
        a.append(pwd)

        h24.fileWriteLines("/home/sambapasswd.tmp",a)
Exemple #2
0
def removeCifsShare (origDirName):
        hasfind = False
        hasfilt = False
        #print origDirName
        line = h23.getContent("/etc/samba/smb.conf")
        i = 0

        while i < len(line):
                if line[i].find("path =") != -1:
                        j = line[i].find("=")
                        tmpd = line[i][j+1:]
                        tmpd = tmpd.strip()
                        #print tmpd
                        if tmpd == origDirName:
                                hasfind = True
                                i += 1
                                if line[i].find("veto files") !=-1:
                                        hasfilt = True
                                break
                i += 1

        if hasfind == False:
                return 0

        if hasfind == True:
                i -= 2
                k = 7
                if hasfilt == True:
                        k = 8
                del line[i:i+k]

        h24.fileWriteLines("/etc/samba/smb.conf",line)
        h25.cpSmbConfig ()
        h26.restartSMB ()
Exemple #3
0
def removeVolumeShare(volumepath):
    hasfind = False
    hasfilt = False
    line = h23.getContent("/etc/samba/smb.conf")
    i = 0

    while i < len(line):
        if line[i].find("path =") != -1:
            j = line[i].find("=")
            tmpd = line[i][j + 1:]
            tmpd = tmpd.strip()
            if tmpd.find(volumepath) != -1:
                hasfind = True
                i += 1
                if line[i].find("veto files") != -1:
                    hasfilt = True
                break
        i += 1

    if hasfind == False:
        return 0

    if hasfind == True:
        i -= 2
        k = 7
        if hasfilt == True:
            k = 8
        del line[i:i + k]

    h24.fileWriteLines("/etc/samba/smb.conf", line)
    h25.cpSmbConfig()
    h26.restartSMB()
Exemple #4
0
def editDirShare(origDirName, shareDirName, *shareInfo):
    shareName = "[" + shareDirName + "]"
    shareName.lower()
    sharePath = "\tpath = " + origDirName
    i = 0
    writelist = "\0"
    readlist = "\0"

    #        print shareInfo
    while i < len(shareInfo[0]):
        if shareInfo[0][i][1] == 0:
            if shareInfo[0][i][2] == 1:
                readlist += ",@"
                readlist += shareInfo[0][i][0]
            else:
                readlist += ","
                readlist += shareInfo[0][i][0]
            i = i + 1
        else:
            if shareInfo[0][i][2] == 1:
                writelist += ",@"
                writelist += shareInfo[0][i][0]
            else:
                writelist = writelist + ","
                writelist += shareInfo[0][i][0]
            i = i + 1

    if len(readlist) != 0:
        readlist = readlist[2:]

    if len(writelist) != 0:
        writelist = writelist[2:]

    validusers = "\tvalid users = " + readlist

    if len(readlist) != 0:
        if len(writelist) != 0:
            validusers += "," + writelist

    readlist = "\tread list = " + readlist
    writelist = "\twrite list = " + writelist
    #print readlist
    #print writelist

    line = h22.hasFind(shareName, sharePath, readlist, writelist, validusers,
                       origDirName, shareDirName)
    #print line
    if line == 0:
        return 0
    if line != 0:
        h24.fileWriteLines("/etc/samba/smb.conf", line)
        h25.cpSmbConfig()
        h26.restartSMB()
    return 1
Exemple #5
0
def editDirShare (origDirName,shareDirName,*shareInfo):
        shareName = "[" +shareDirName + "]"
        shareName.lower ()
        sharePath = "\tpath = " + origDirName
        i = 0
        writelist = "\0"
        readlist = "\0"

#        print shareInfo
        while i < len(shareInfo[0]):
                if shareInfo[0][i][1] == 0:
                        if shareInfo[0][i][2] == 1:
                                readlist += ",@"
                                readlist += shareInfo[0][i][0]
                        else:
                                readlist += ","
                                readlist += shareInfo[0][i][0]
                        i = i + 1
                else:
                        if shareInfo[0][i][2] == 1:
                                writelist += ",@"
                                writelist += shareInfo[0][i][0]
                        else:
                                writelist = writelist + ","
                                writelist += shareInfo[0][i][0]
                        i = i + 1

        if len(readlist)!=0:
                readlist = readlist[2:]

        if len(writelist) != 0:
                writelist = writelist[2:]

        validusers = "\tvalid users = " + readlist

        if len(readlist) != 0:
                if len(writelist) != 0:
                        validusers += "," + writelist

        readlist = "\tread list = " + readlist
        writelist = "\twrite list = " + writelist
        #print readlist
        #print writelist

        line = h22.hasFind (shareName, sharePath, readlist, writelist, validusers, origDirName, shareDirName)
        #print line
        if line == 0:
                return 0
        if line != 0:
                h24.fileWriteLines("/etc/samba/smb.conf", line)
                h25.cpSmbConfig ()
                h26.restartSMB ()
        return 1
Exemple #6
0
def cpSmbConfig():
    a = []
    line = h23.getContent("/etc/samba/smb.conf")
    i = 0
    while i < len(line):
        if line[i].find("valid users =") != -1:
            j = line[i].find("=")
            tmp = line[i][j + 1:]
            tmp = tmp.strip()
            tmp1 = re.split(r',', tmp)
            j = 0
            while j < len(tmp1):
                a.append(tmp1[j])
                j = j + 1
        i = i + 1
    os.system("rm -rf /sysvol/etc/samba/smb.conf.*")
    #print a

    k = 0
    while k < len(a):
        str = "\\cp /sysvol/etc/samba/smb.conf /sysvol/etc/samba/smb.conf." + a[
            k].strip()
        os.system(str)
        #print str
        k = k + 1

    k = 0
    while k < len(a):
        filepath = "/sysvol/etc/samba/smb.conf." + a[k].strip()
        tmp2 = h23.getContent(filepath)
        #print len(tmp2)
        j = 0
        while j < len(tmp2):
            if tmp2[j].find('valid users =') != -1:
                b = []
                hasfind = 0
                #print j
                #print len(tmp2)
                l = tmp2[j].find("=")
                tmp3 = tmp2[j][l + 1:]
                #print tmp3
                tmp3 = tmp3.strip()
                tmp4 = re.split(r',', tmp3)
                #print tmp4
                n = 0
                while n < len(tmp4):
                    b.append(tmp4[n])
                    n = n + 1
                m = 0
                while m < len(b):
                    #print b[m]
                    #print a[k]
                    if b[m] == a[k]:
                        hasfind = 1
                        break
                    m = m + 1
                if hasfind == 1:
                    #print "GGGGGGGG"
                    #print tmp2
                    tmp2[j - 1:0] = ["\tbrowseable = no\n"]
                    #print tmp2
                    #print j
                    j = j + 1
                    #print j
                else:
                    j = j + 1
                j = j + 1
            else:
                j = j + 1
        #print filepath
        #print tmp2
        h24.fileWriteLines(filepath, tmp2)
        k = k + 1
Exemple #7
0
def cpSmbConfig():
    a = []
    line = h23.getContent("/etc/samba/smb.conf")
    i = 0
    while i < len(line):
        if line[i].find("valid users =") != -1:
            j = line[i].find("=")
            tmp = line[i][j + 1 :]
            tmp = tmp.strip()
            tmp1 = re.split(r",", tmp)
            j = 0
            while j < len(tmp1):
                a.append(tmp1[j])
                j = j + 1
        i = i + 1
    os.system("rm -rf /sysvol/etc/samba/smb.conf.*")
    # print a

    k = 0
    while k < len(a):
        str = "\\cp /sysvol/etc/samba/smb.conf /sysvol/etc/samba/smb.conf." + a[k].strip()
        os.system(str)
        # print str
        k = k + 1

    k = 0
    while k < len(a):
        filepath = "/sysvol/etc/samba/smb.conf." + a[k].strip()
        tmp2 = h23.getContent(filepath)
        # print len(tmp2)
        j = 0
        while j < len(tmp2):
            if tmp2[j].find("valid users =") != -1:
                b = []
                hasfind = 0
                # print j
                # print len(tmp2)
                l = tmp2[j].find("=")
                tmp3 = tmp2[j][l + 1 :]
                # print tmp3
                tmp3 = tmp3.strip()
                tmp4 = re.split(r",", tmp3)
                # print tmp4
                n = 0
                while n < len(tmp4):
                    b.append(tmp4[n])
                    n = n + 1
                m = 0
                while m < len(b):
                    # print b[m]
                    # print a[k]
                    if b[m] == a[k]:
                        hasfind = 1
                        break
                    m = m + 1
                if hasfind == 1:
                    # print "GGGGGGGG"
                    # print tmp2
                    tmp2[j - 1 : 0] = ["\tbrowseable = no\n"]
                    # print tmp2
                    # print j
                    j = j + 1
                    # print j
                else:
                    j = j + 1
                j = j + 1
            else:
                j = j + 1
        # print filepath
        # print tmp2
        h24.fileWriteLines(filepath, tmp2)
        k = k + 1