Author: fehr
Date: Mon Jun 25 17:48:13 2007
New Revision: 39013
URL: http://svn.opensuse.org/viewcvs/yast?rev=39013&view=rev
Log:
prevent direct or indirect change of partitions used for swap or
as install source during installation (#274321,#262417)
Modified:
trunk/storage/libstorage/src/Storage.cc
trunk/storage/libstorage/src/Volume.cc
trunk/storage/libstorage/src/Volume.h
trunk/storage/package/yast2-storage.changes
trunk/storage/storage/src/include/auto_part_prepare.ycp
trunk/storage/storage/src/include/custom_part_check_generated.ycp
trunk/storage/storage/src/include/custom_part_lib.ycp
trunk/storage/storage/src/include/do_proposal_flexible.ycp
trunk/storage/storage/src/include/evms_lib.ycp
trunk/storage/storage/src/include/signatures.ycp
trunk/storage/storage/src/inst_custom_part.ycp
trunk/storage/storage/src/inst_lvm_lv.ycp
trunk/storage/storage/src/inst_target_part.ycp
trunk/storage/storage/src/modules/Storage.ycp
Modified: trunk/storage/libstorage/src/Storage.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/Storage.cc?rev=39013&r1=39012&r2=39013&view=diff
==============================================================================
--- trunk/storage/libstorage/src/Storage.cc (original)
+++ trunk/storage/libstorage/src/Storage.cc Mon Jun 25 17:48:13 2007
@@ -829,8 +829,7 @@
{
if( i->getUsedByType()==UB_NONE )
{
- if( detectMounted )
- i->getMountData( Mounts );
+ i->getMountData( Mounts, !detectMounted );
i->getFstabData( *fstab );
y2mil( "detect:" << *i );
if( i->getFs()==FSUNKNOWN && i->getEncryption()==ENC_NONE )
Modified: trunk/storage/libstorage/src/Volume.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/Volume.cc?rev=39013&r1=39012&r2=39013&view=diff
==============================================================================
--- trunk/storage/libstorage/src/Volume.cc (original)
+++ trunk/storage/libstorage/src/Volume.cc Mon Jun 25 17:48:13 2007
@@ -268,10 +268,10 @@
}
}
-void Volume::getMountData( const ProcMounts& mountData )
+void Volume::getMountData( const ProcMounts& mountData, bool swap_only )
{
y2mil( "this:" << *this );
- y2mil( "mountDevice:" << mountDevice() );
+ y2mil( "swap_only:" << swap_only << " mountDevice:" << mountDevice() );
mp = mountData.getMount( mountDevice() );
if( mp.empty() )
{
@@ -280,7 +280,13 @@
if( !mp.empty() )
{
is_mounted = true;
- y2milestone( "%s mounted on %s", device().c_str(), mp.c_str() );
+ if( swap_only && mp!="swap" )
+ {
+ is_mounted = false;
+ mp.clear();
+ }
+ if( is_mounted )
+ y2milestone( "%s mounted on %s", device().c_str(), mp.c_str() );
}
orig_mp = mp;
}
Modified: trunk/storage/libstorage/src/Volume.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/Volume.h?rev=39013&r1=39012&r2=39013&view=diff
==============================================================================
--- trunk/storage/libstorage/src/Volume.h (original)
+++ trunk/storage/libstorage/src/Volume.h Mon Jun 25 17:48:13 2007
@@ -199,7 +199,7 @@
bool allowedMountBy( storage::MountByType mby, const string& mp="" );
void getFsData( SystemCmd& blkidData );
void getLoopData( SystemCmd& loopData );
- void getMountData( const ProcMounts& mountData );
+ void getMountData( const ProcMounts& mountData, bool swap_only=false );
void getFstabData( EtcFstab& fstabData );
void getStartData();
void getTestmodeData( const string& data );
Modified: trunk/storage/package/yast2-storage.changes
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/package/yast2-storage.changes?rev=39013&r1=39012&r2=39013&view=diff
==============================================================================
--- trunk/storage/package/yast2-storage.changes (original)
+++ trunk/storage/package/yast2-storage.changes Mon Jun 25 17:48:13 2007
@@ -2,6 +2,8 @@
Mon Jun 25 17:41:27 CEST 2007 - fehr@suse.de
- fixed problem mounting filesystem in inst-sys (#286686)
+- prevent direct or indirect change of partitions used for swap or
+ as install source during installation (#274321,#262417)
-------------------------------------------------------------------
Mon Jun 18 12:48:04 CEST 2007 - fehr@suse.de
Modified: trunk/storage/storage/src/include/auto_part_prepare.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/storage/src/include/auto_part_prepare.ycp?rev=39013&r1=39012&r2=39013&view=diff
==============================================================================
--- trunk/storage/storage/src/include/auto_part_prepare.ycp (original)
+++ trunk/storage/storage/src/include/auto_part_prepare.ycp Mon Jun 25 17:48:13 2007
@@ -161,7 +161,7 @@
p["ui_id"] = ui_id;
if( p["type"]:`unknown == `free )
p["size_k"] = size_of_region( p["region"]:[0,0], bytes_per_unit )/1024;
- if( haskey(p,"mount"))
+ if( haskey(p,"mount") && p["mount"]:""!="swap" && !p["inactive"]:false )
p = remove( p, "mount" );
return( p );
});
Modified: trunk/storage/storage/src/include/custom_part_check_generated.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/storage/src/include/custom_part_check_generated.ycp?rev=39013&r1=39012&r2=39013&view=diff
==============================================================================
--- trunk/storage/storage/src/include/custom_part_check_generated.ycp (original)
+++ trunk/storage/storage/src/include/custom_part_check_generated.ycp Mon Jun 25 17:48:13 2007
@@ -825,11 +825,14 @@
Remove the volume before editing it.
"), curr_part["used_by"]:"" ));
}
- return( used==`UB_NONE );
+ boolean ret = used==`UB_NONE;
+ if( ret )
+ ret = Storage::CanEdit( curr_part, true );
+ return( ret );
}
define boolean check_device_delete( map curr_part, boolean bsd_label,
- boolean installation, list<map> pl )
+ boolean installation, map disk )
``{
string part_name = curr_part["device"]:"";
@@ -930,10 +933,11 @@
}
}
}
- if( curr_part["type"]:`unknown==`logical )
+ if( !installation && curr_part["type"]:`unknown==`logical )
{
boolean ok = true;
- list<map> ppl = filter( map p, pl, ``(p["nr"]:0>curr_part["nr"]:0));
+ list<map> ppl = filter( map p, disk["partitions"]:[],
+ ``(p["nr"]:0>curr_part["nr"]:0));
if( size(ppl)>0 && check_devices_used( ppl, true )!=`UB_NONE )
ok = false;
if( ok && !installation && size(ppl)>0 )
@@ -956,7 +960,10 @@
return( false );
}
}
- return true;
+ boolean ret = used==`UB_NONE;
+ if( ret )
+ ret = Storage::CanDelete( curr_part, disk, true );
+ return ret;
};
@@ -1057,7 +1064,15 @@
deleting the extended partition.
"));
}
- return( used==`UB_NONE );
+ boolean ret = used==`UB_NONE;
+ if( ret )
+ {
+ map extd = find( map p, partitions,
+ ``(p["type"]:`primary==`extended));
+ if( extd!=nil && size(extd)>0 )
+ ret = Storage::CanDelete( extd, curr_disk, true );
+ }
+ return( ret );
};
}
Modified: trunk/storage/storage/src/include/custom_part_lib.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/storage/src/include/custom_part_lib.ycp?rev=39013&r1=39012&r2=39013&view=diff
==============================================================================
--- trunk/storage/storage/src/include/custom_part_lib.ycp (original)
+++ trunk/storage/storage/src/include/custom_part_lib.ycp Mon Jun 25 17:48:13 2007
@@ -418,6 +418,8 @@
ret["ok"] = true;
new["mount"] = UI::QueryWidget(`id(`mount_point), `Value);
new["mount"] = deletechars( new["mount"]:"", " \t" );
+ if( old["mount"]:"" != new["mount"]:"" )
+ new["inactive"] = true;
if( ret["ok"]:false && size(new["mount"]:"")>0 )
{
boolean crypt_fs = false;
@@ -643,7 +645,10 @@
{
not_used_mp = selected_fs[`mountpoints]:[];
if( mount != "swap" && (new["type"]:`primary!=`lvm || mount!=""))
+ {
new["mount"] = "swap";
+ new["inactive"] = true;
+ }
}
else
{
Modified: trunk/storage/storage/src/include/do_proposal_flexible.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/storage/src/include/do_proposal_flexible.ycp?rev=39013&r1=39012&r2=39013&view=diff
==============================================================================
--- trunk/storage/storage/src/include/do_proposal_flexible.ycp (original)
+++ trunk/storage/storage/src/include/do_proposal_flexible.ycp Mon Jun 25 17:48:13 2007
@@ -821,6 +821,8 @@
{
y2milestone( "process_partition_data reuse part %1", p );
p["format"] = true;
+ if( p["mount"]:"" != mount )
+ p["inactive"] = true;
p["mount"] = mount;
p["used_fs"] =
solution["partitions",pindex,"fsys"]:Partitions::DefaultFs();
@@ -920,6 +922,7 @@
}
part["size_k"] = part["region",1]:0 * disk["cyl_size"]:0 / 1024;
part["mount"] = mount;
+ part["inactive"] = true;
part["used_fs"] =
solution["partitions",pindex,"fsys"]:Partitions::DefaultFs();
value = solution["partitions",pindex,"fstopt"]:"";
@@ -1002,6 +1005,7 @@
part["type"] = `logical;
}
part["mount"] = mount;
+ part["inactive"] = true;
part["used_fs"] =
solution["partitions",pindex,"fsys"]:Partitions::DefaultFs();
value = solution["partitions",pindex,"fstopt"]:"";
@@ -1633,7 +1637,8 @@
p["type"]:`primary != `extended &&
!contains( conf["keep_partition_num"]:[], p["nr"]:0 ) &&
!contains( conf["keep_partition_id"]:[], fsid ) &&
- !contains( conf["keep_partition_fsys"]:[], p["used_fs"]:`none ))
+ !contains( conf["keep_partition_fsys"]:[], p["used_fs"]:`none ) &&
+ Storage::CanDelete( p, disk, false ))
{
p["delete"] = true;
}
@@ -2206,6 +2211,8 @@
if( !p["delete"]:false &&
p["device"]:""==swaps[0,"device"]:"" )
{
+ if( p["mount"]:"" != "swap" )
+ p["inactive"] = true;
p["mount"] = "swap";
if( haskey( p, "vg" ))
{
@@ -2278,8 +2285,9 @@
{
ret = maplist( map p, partitions,
``{
- if( !p["delete"]:false &&
- p["device"]:""==boot["device"]:"" )
+ if( !p["delete"]:false &&
+ p["device"]:""==boot["device"]:"" &&
+ Storage::CanEdit(p,false) )
{
p["mount"] = Partitions::BootMount();
p["used_fs"] = Partitions::DefaultBootFs();
@@ -2312,7 +2320,8 @@
p["used_by_type"]:`UB_NONE == `UB_NONE &&
size(p["mount"]:"")==0 &&
p["size_k"]:0/1024 >= min &&
- (max==0 || p["size_k"]:0/1024 <= max)));
+ (max==0 || p["size_k"]:0/1024 <= max) &&
+ Storage::CanEdit( p, false )));
y2milestone( "can_mp_reuse normal %1", pl );
if( size(pl)>0 )
{
@@ -2563,11 +2572,12 @@
parts =
maplist( map p, parts,
``{
- if( size(mp)==0 || contains( mp, p["mount"]:"") )
+ if( (size(mp)==0 || contains( mp, p["mount"]:"")) &&
+ !(p["mount"]:""=="swap" && !p["inactive"]:false) )
{
foreach( string s, rems,
``{
- if( haskey( p, s ))
+ if( haskey( p, s ) )
p = remove( p, s );
});
}
@@ -2576,8 +2586,9 @@
return( parts );
}
-list<map> remove_one_partition( list<map> partitions )
+list<map> remove_one_partition( map disk )
{
+ list<map> partitions = disk["partitions"]:[];
list<map> pl = filter( map p, partitions,
``( p["linux"]:false && size(p["mount"]:"")==0 &&
!p["delete"]:false ));
@@ -2594,7 +2605,8 @@
``{
if( p["linux"]:false && !p["delete"]:false &&
size(p["mount"]:"")==0 &&
- p["device"]:""==pl[0,"device"]:"" )
+ p["device"]:""==pl[0,"device"]:"" &&
+ Storage::CanDelete( p, disk, false ))
{
p["delete"] = true;
y2milestone( "remove_one_partition p %1", p );
@@ -2631,7 +2643,8 @@
``{
if( p["linux"]:false && !p["delete"]:false &&
size(p["mount"]:"")==0 &&
- p["device"]:""==pl[0,"device"]:"" )
+ p["device"]:""==pl[0,"device"]:"" &&
+ Storage::CanDelete( p, disk, false ))
{
p["delete"] = true;
nr = p["nr"]:0;
@@ -2711,7 +2724,8 @@
maplist( map p, target[s,"partitions"]:[],
``{
if( !contains( Partitions::do_not_delete,
- p["fsid"]:0 ))
+ p["fsid"]:0 ) &&
+ Storage::CanDelete( p, target[s]:$[], false))
{
if( usable_for_win_resize(p,false) )
p["dtxt"] = _("Resize impossible due to inconsistent fs. Try checking fs under Windows.");
@@ -2744,7 +2758,7 @@
foreach( string s, filter( string d, ddev, ``(valid[d]:false)),
``{
target[s,"partitions"] =
- remove_one_partition( target[s,"partitions"]:[] );
+ remove_one_partition( target[s]:$[] );
});
}
}
@@ -3499,7 +3513,8 @@
maplist( map p, target[s,"partitions"]:[],
``{
if( !contains( Partitions::do_not_delete,
- p["fsid"]:0 ))
+ p["fsid"]:0 ) &&
+ Storage::CanDelete( p, target[s]:$[], false))
{
if( usable_for_win_resize(p,false) )
p["dtxt"] = _("Resize impossible due to inconsistent fs. Try checking fs under Windows.");
Modified: trunk/storage/storage/src/include/evms_lib.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/storage/src/include/evms_lib.ycp?rev=39013&r1=39012&r2=39013&view=diff
==============================================================================
--- trunk/storage/storage/src/include/evms_lib.ycp (original)
+++ trunk/storage/storage/src/include/evms_lib.ycp Mon Jun 25 17:48:13 2007
@@ -1323,7 +1323,7 @@
%1 is not a logical volume produced by a container.
"), device ));
}
- else if( check_device_delete( part, false, Mode::installation(), [] ))
+ else if( check_device_delete( part, false, Mode::installation(), $[] ))
{
string txt = sformat( _("Really delete %1?"), part["device"]:"" );
if( Popup::YesNo( txt ) )
Modified: trunk/storage/storage/src/include/signatures.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/storage/src/include/signatures.ycp?rev=39013&r1=39012&r2=39013&view=diff
==============================================================================
--- trunk/storage/storage/src/include/signatures.ycp (original)
+++ trunk/storage/storage/src/include/signatures.ycp Mon Jun 25 17:48:13 2007
@@ -11,7 +11,7 @@
boolean CheckFstabOptions( map part );
symbol check_devices_used( list<map> partitions, boolean not_cr );
boolean check_device_delete( map curr_part, boolean bsd_label,
- boolean installation, list<map> pl );
+ boolean installation, map disk );
list<map> get_possible_pvs( map