/[smeserver]/rpms/e-smith-backup/sme10/e-smith-backup-2.6.0-replacehal.patch
ViewVC logotype

Annotation of /rpms/e-smith-backup/sme10/e-smith-backup-2.6.0-replacehal.patch

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (hide annotations) (download)
Sat Jan 30 20:30:14 2021 UTC (3 years, 9 months ago) by chrissn
Branch: MAIN
CVS Tags: e-smith-backup-2_6_0-20_el7_sme
* Sat Jan 30 2021 Chris Sansom-Ninnes <chris@sansom.ninnes.net> 2.6.0-20.sme
- Replace hal-* calls with BlockDevices [SME: 11319]

1 chrissn 1.1 diff -urN e-smith-backup-2.6.0.old/root/etc/e-smith/events/actions/workstation-backup-dar e-smith-backup-2.6.0/root/etc/e-smith/events/actions/workstation-backup-dar
2     --- e-smith-backup-2.6.0.old/root/etc/e-smith/events/actions/workstation-backup-dar 2021-01-30 20:13:44.698955067 +0000
3     +++ e-smith-backup-2.6.0/root/etc/e-smith/events/actions/workstation-backup-dar 2021-01-30 20:18:00.982571819 +0000
4     @@ -31,6 +31,7 @@
5     use File::Glob qw(bsd_glob);
6     use esmith::ConfigDB;
7     use esmith::Backup;
8     +use esmith::BlockDevices;
9    
10     sub ldie;
11     sub start_dar_killer;
12     @@ -312,77 +313,61 @@
13     return $code;
14     }
15    
16     -
17     +# Copied from /etc/e-smith/web/functions/backup
18     +# TODO: Move to a shared module
19     sub checkMount
20     {
21     # check if $mountdir is mounted
22     my $mountdir = shift;
23     $|=1; # Auto-flush
24     -
25     - # copy STDOUT to another filehandle
26     - open (my $STDOLD, '>&', STDOUT);
27     -
28     - open(STDOUT, ">/dev/null");
29     - if ( open(MOUNTDIR, "|-", "/bin/findmnt", $mountdir)){;}
30    
31     - # restore STDOUT
32     - open (STDOUT, '>&', $STDOLD);
33     -
34     - return (!close(MOUNTDIR));
35     + my @res = qx( findmnt $mountdir );
36     + return ( !@res );
37     }
38    
39    
40     -# dmount is copied from /etc/e-smith/web/functions/backup
41     -# it could become a common function later
42     +# Copied from /etc/e-smith/web/functions/backup
43     +# TODO: Move to a shared module
44     sub dmount
45     {
46     # mount dar unit according to dar-workstation configuration
47     # return nothing if mount successfull
48    
49     my ($host,$share,$mountdir,$login,$password,$VFSType) = @_;
50     -
51     +
52     if ($VFSType eq 'cifs')
53     {
54     - return ( qx(/bin/mount -t cifs "//$host/$share" $mountdir -o credentials=/etc/dar/CIFScredentials,nounix 2>&1) );
55     + return ( qx(/bin/mount -t cifs "//$host/$share" $mountdir -o credentials=/etc/dar/CIFScredentials,nounix 2>&1) );
56     }
57     elsif ($VFSType eq 'nfs')
58     {
59     - return ( qx(/bin/mount -t nfs -o nolock "$host:/$share" $mountdir 2>&1) );
60     + return ( qx(/bin/mount -t nfs -o nolock "$host:/$share" $mountdir 2>&1) );
61     }
62     elsif ($VFSType eq 'usb')
63     {
64     my $device = "";
65     - my $blkdev = "";
66     my $vollbl = "";
67     - foreach my $udi (qx(hal-find-by-property --key volume.fsusage --string filesystem))
68     - {
69     - $udi =~ m/^(\S+)/;
70     - my $is_mounted = qx(hal-get-property --udi $1 --key volume.is_mounted);
71    
72     - if ($is_mounted eq "false\n")
73     - {
74     - $blkdev = qx(hal-get-property --udi $1 --key block.device);
75     - if ($blkdev =~ m/^(\S+)/) {$blkdev = $1;}
76     - }
77     - if ($is_mounted eq "false\n")
78     - {
79     - $vollbl = qx(hal-get-property --udi $1 --key volume.label);
80     - $vollbl =~ m/^(\S+)/;
81     - if ($vollbl =~ /^\s/) {$vollbl = 'nolabel';}
82     - }
83     + my $devices = esmith::BlockDevices->new ('allowmount' => 'disabled');
84     + my ($valid, $invalid) = $devices->checkBackupDrives(0, 1);
85    
86     - chomp $vollbl;
87     - chomp $blkdev;
88     - $vollbl = "media/$vollbl";
89     - if ($vollbl eq $share) {$device = $blkdev;}
90     + if ( ${$valid}[0] ) {
91     + foreach ( @{$valid} ) {
92     + warn $_;
93     + $vollbl = $devices->label($_);
94     + if ( $share eq "media/$vollbl" ) {
95     + $device = "/dev/$_";
96     + }
97     + }
98     }
99     - return ( qx(/bin/mount $device "/$share" 2>&1) );
100     + $devices->destroy;
101     + return ( qx (mount $device /$share 2>&1) );
102     }
103     else
104     {
105     - return ("Mount of type $VFSType not supported.\n");
106     + return ("Error while mounting $host/$share : $VFSType not supported.\n");
107     }
108     -}
109     +}
110    
111    
112     sub removeTree
113     diff -urN e-smith-backup-2.6.0.old/root/etc/e-smith/web/functions/backup e-smith-backup-2.6.0/root/etc/e-smith/web/functions/backup
114     --- e-smith-backup-2.6.0.old/root/etc/e-smith/web/functions/backup 2021-01-30 20:13:44.674956230 +0000
115     +++ e-smith-backup-2.6.0/root/etc/e-smith/web/functions/backup 2021-01-30 20:17:32.531942610 +0000
116     @@ -27,6 +27,7 @@
117     use esmith::ConfigDB;
118     use esmith::Backup;
119     use esmith::BackupHistoryDB;
120     +use esmith::BlockDevices;
121     use esmith::AccountsDB;
122     use esmith::cgi;
123     use esmith::util;
124     @@ -697,9 +698,9 @@
125     if (defined $status && $status eq "on")
126     {
127    
128     - #--------------------------------------------------
129     - # Untaint parameters and check for validity
130     - #--------------------------------------------------
131     + #--------------------------------------------------
132     + # Untaint parameters and check for validity
133     + #--------------------------------------------------
134    
135     my $backupHour = $q->param ('backupHour');
136     if ($backupHour =~ /^(.*)$/) {
137     @@ -1237,23 +1238,20 @@
138     $q, undef, $fm->localise('CONFIGURE_WORKSTN_BACKUP'));
139    
140     if ( $VFSType eq 'usb' ) {
141     - foreach my $udi (qx(hal-find-by-property --key volume.fsusage --string filesystem)) {
142     - $udi =~ m/^(\S+)/;
143     + my $devices = esmith::BlockDevices->new ('allowmount' => 'disabled');
144     + my ($valid, $invalid) = $devices->checkBackupDrives(0, 1);
145    
146     - my $is_mounted = qx(hal-get-property --udi $1 --key volume.is_mounted);
147     -
148     - if ($is_mounted eq "false\n") {
149     - my $vollbl = qx(hal-get-property --udi $1 --key volume.label);
150     - $vollbl =~ m/^(\S+)/;
151     - if ($vollbl =~ /^\s/) {$vollbl = 'nolabel';}
152     - chomp $vollbl;
153     - push @usbdisks, $vollbl;
154     + if ( ${$valid}[0] ) {
155     + foreach ( @{$valid} ) {
156     + push @usbdisks, $devices->label($_);
157     }
158     }
159     - unless ($usbdisks[0]){
160     + else
161     + {
162     push @usbdisks, $fm->localise('ERR_NO_USB_DISK');
163     $error='nousb';
164     }
165     + $devices->destroy;
166     }
167     if ( $VFSType eq 'mnt' )
168     {
169     @@ -1509,9 +1507,9 @@
170     return;
171     }
172    
173     - #--------------------------------------------------
174     - # Untaint parameters and check for validity
175     - #--------------------------------------------------
176     + #--------------------------------------------------
177     + # Untaint parameters and check for validity
178     + #--------------------------------------------------
179    
180     my $VFSType = $q->param ('VFSType');
181     if ( $VFSType eq 'nousb')
182     @@ -3007,7 +3005,7 @@
183     my $dumpsize = 0;
184    
185     open(DF, "-|")
186     - or exec '/bin/df', '-P', '-t', 'ext3', '-t', 'ext4';
187     + or exec '/bin/df', '-P', '-t', 'ext3', '-t', 'ext4', '-t', 'xfs';
188    
189     while (<DF>)
190     {
191     @@ -3034,7 +3032,7 @@
192     my $halffree = 0;
193    
194     open(DF, "-|")
195     - or exec '/bin/df', '-P', '-t', 'ext3', '-t', 'ext4', '/tmp';
196     + or exec '/bin/df', '-P', '-t', 'ext3', '-t', 'ext4', '-t', 'xfs', '/tmp';
197    
198     while (<DF>)
199     {
200     @@ -3106,30 +3104,21 @@
201     elsif ($VFSType eq 'usb')
202     {
203     my $device = "";
204     - my $blkdev = "";
205     my $vollbl = "";
206     - foreach my $udi (qx(hal-find-by-property --key volume.fsusage --string filesystem)) {
207     - $udi =~ m/^(\S+)/;
208     - my $is_mounted = qx(hal-get-property --udi $1 --key volume.is_mounted);
209     -
210     - if ($is_mounted eq "false\n") {
211     - $blkdev = qx(hal-get-property --udi $1 --key block.device);
212     - if ($blkdev =~ m/^(\S+)/) {$blkdev = $1;}
213     - }
214     - if ($is_mounted eq "false\n") {
215     - $vollbl = qx(hal-get-property --udi $1 --key volume.label);
216     - $vollbl =~ m/^(\S+)/;
217     - if ($vollbl =~ /^\s/) {$vollbl = 'nolabel';}
218     - }
219     -
220     - chomp $vollbl;
221     - chomp $blkdev;
222     - $vollbl = "media/$vollbl";
223     - if ($vollbl eq $share) {
224     - $device = $blkdev;
225     - }
226     +
227     + my $devices = esmith::BlockDevices->new ('allowmount' => 'disabled');
228     + my ($valid, $invalid) = $devices->checkBackupDrives(0, 1);
229     +
230     + if ( ${$valid}[0] ) {
231     + foreach ( @{$valid} ) {
232     + $vollbl = $devices->label($_);
233     + if ( $share eq "media/$vollbl" ) {
234     + $device = "/dev/$_";
235     + }
236     + }
237     }
238     - return ( qx(/bin/mount $device "/$share" 2>&1) );
239     + $devices->destroy;
240     + return ( qx (mount $device /$share 2>&1) );
241     }
242     else
243     {
244     @@ -3142,17 +3131,9 @@
245     # check if $mountdir is mounted
246     my $mountdir = shift;
247     $|=1; # Auto-flush
248     -
249     - # copy STDOUT to another filehandle
250     - open (my $STDOLD, '>&', STDOUT);
251     -
252     - open(STDOUT, ">/dev/null");
253     - if ( open(MOUNTDIR, "|-", "/bin/findmnt", $mountdir)){;}
254     -
255     - # restore STDOUT
256     - open (STDOUT, '>&', $STDOLD);
257     -
258     - return (!close(MOUNTDIR));
259     +
260     + my @res = qx( findmnt $mountdir );
261     + return ( !@res );
262     }
263    
264     sub bmount
265     diff -urN e-smith-backup-2.6.0.old/root/usr/share/perl5/vendor_perl/esmith/BlockDevices.pm e-smith-backup-2.6.0/root/usr/share/perl5/vendor_perl/esmith/BlockDevices.pm
266     --- e-smith-backup-2.6.0.old/root/usr/share/perl5/vendor_perl/esmith/BlockDevices.pm 2021-01-30 20:13:44.702954873 +0000
267     +++ e-smith-backup-2.6.0/root/usr/share/perl5/vendor_perl/esmith/BlockDevices.pm 2021-01-30 20:16:39.613490616 +0000
268     @@ -200,7 +200,7 @@
269     # Return two arrays, valid drives, invalid drives
270     sub checkBackupDrives
271     {
272     - my ($self,$bsize) = @_;
273     + my ($self,$bsize,$removable) = @_;
274     my @valid = ();
275     my @invalid = ();
276     $self->scanBlocks; # scan all block devices
277     @@ -209,6 +209,7 @@
278     my $checks = 'UU RO FS'; # These checks are always valid
279     $checks .= ' MO' if ($allowmount eq 'enabled');
280     $checks .= ' SZ' if ($bsize); # Only run the size check when a valid size is given
281     + $checks .= ' RM' if ($removable); # Only run the removable check if asked
282    
283     foreach my $drive (keys %{$hashref})
284     {
285     @@ -239,6 +240,10 @@
286     {
287     $hashref->{$drive}{REASON} .='MO ' if $self->mountpoint ($drive); last;
288     }
289     + if (/^RM/si) # Non-removable
290     + {
291     + $hashref->{$drive}{REASON} .='RM ' unless $self->removable ($drive); last;
292     + }
293     if (/^SZ/si) # filesystem size, this includes mounting to check free space
294     {
295     $hashref->{$drive}{REASON} .='SZ ' if $self->checkBackupDriveSize ($drive, $bsize);
296     @@ -360,13 +365,20 @@
297     return ($hashref->{$kname}{MODEL});
298     }
299    
300     +sub removable
301     +{
302     + my ($self,$kname) = @_;
303     + my $hashref = $self->{_blox};
304     + return ($hashref->{$kname}{RM}) ? 1 : $EMPTY;
305     +}
306     +
307     # Given the KNAME return the label
308     # returns 'no label' if none found
309     sub label
310     {
311     my ($self,$kname) = @_;
312     my $hashref = $self->{_blox};
313     - return ($hashref->{$kname}{LABEL}) || gettext('no label');
314     + return ($hashref->{$kname}{LABEL}) || gettext('nolabel');
315     }
316    
317     sub size

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed