summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings2/network
Side-by-side diff
Diffstat (limited to 'noncore/settings/networksettings2/network') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings2/network/network_NNI.cpp47
-rw-r--r--noncore/settings/networksettings2/network/networkrun.cpp4
2 files changed, 36 insertions, 15 deletions
diff --git a/noncore/settings/networksettings2/network/network_NNI.cpp b/noncore/settings/networksettings2/network/network_NNI.cpp
index 054385a..3e368a2 100644
--- a/noncore/settings/networksettings2/network/network_NNI.cpp
+++ b/noncore/settings/networksettings2/network/network_NNI.cpp
@@ -88,65 +88,86 @@ QWidget * ANetwork::edit( QWidget * parent ) {
GUI = new NetworkEdit( parent );
GUI->showData( Data );
return GUI;
}
QString ANetwork::acceptable( void ) {
return ( GUI ) ? GUI->acceptable( ) : QString();
}
void ANetwork::commit( void ) {
if( GUI && GUI->commit( Data ) )
setModified( 1 );
}
bool ANetwork::hasDataFor( const QString & S ) {
return S == "interfaces";
}
bool ANetwork::generateDataForCommonFile( SystemFile & S, long DevNr ) {
QString NIC = runtime()->device()->netNode()->nodeClass()->genNic( DevNr );
if( S.name() == "interfaces" ) {
// we can safely call from here since device item is deeper
if( Data.UseDHCP ) {
- S << "iface " << NIC << "-c" << connection()->number() <<
- "-allowed inet dhcp" << endl;
- S << " up echo \"" << NIC << "\" > /tmp/profile-" << connection()->number() <<
- ".up" << Data.IPAddress << endl;
+ S << "iface "
+ << NIC
+ << "-c"
+ << connection()->number()
+ << "-allowed inet dhcp"
+ << endl;
+ S << " up echo \""
+ << NIC
+ << "\" > /tmp/profile-"
+ << connection()->number()
+ << ".up"
+ << endl;
if( Data.SendHostname ) {
- S << " hostname "<< Data.Hostname << endl;
+ S << " hostname "
+ << Data.Hostname
+ << endl;
}
- S << " down rm -f /tmp/profile-" << connection()->number() <<
- ".up" << Data.IPAddress << endl;
+ S << " down rm -f /tmp/profile-"
+ << connection()->number()
+ << ".up"
+ << endl;
} else {
- S << "iface " << NIC << "-c" << connection()->number() <<
- "-allowed inet static" << endl;
- S << " up echo \"" << NIC << "\" > /tmp/profile-" << connection()->number() <<
- ".up" << Data.IPAddress << endl;
- S << " down rm -f /tmp/profile-" << connection()->number() <<
- ".up" << Data.IPAddress << endl;
+ S << "iface "
+ << NIC << "-c"
+ << connection()->number()
+ << "-allowed inet static"
+ << endl;
+ S << " up echo \""
+ << NIC
+ << "\" > /tmp/profile-"
+ << connection()->number()
+ << ".up"
+ << endl;
+ S << " down rm -f /tmp/profile-"
+ << connection()->number()
+ << ".up"
+ << endl;
S << " address " << Data.IPAddress << endl;
S << " broadcast " << Data.Broadcast << endl;
S << " netmask " << Data.NetMask << endl;
// derive network address = IPAddress & netmask
{ QString NW;
QStringList ipal = QStringList::split( '.', Data.IPAddress );
QStringList nmal = QStringList::split( '.', Data.NetMask );
NW = QString( "%1.%2.%3.%4" ).
arg( ipal[0].toShort() & nmal[0].toShort() ).
arg( ipal[1].toShort() & nmal[1].toShort() ).
arg( ipal[2].toShort() & nmal[2].toShort() ).
arg( ipal[3].toShort() & nmal[3].toShort() );
S << " network " << NW << endl;
}
}
for ( QStringList::Iterator it = Data.PreUp_SL.begin();
it != Data.PreUp_SL.end();
++it ) {
S << " pre-up " << (*it) << endl;
}
for ( QStringList::Iterator it = Data.PostUp_SL.begin();
it != Data.PostUp_SL.end();
diff --git a/noncore/settings/networksettings2/network/networkrun.cpp b/noncore/settings/networksettings2/network/networkrun.cpp
index ddb9a5f..c19235a 100644
--- a/noncore/settings/networksettings2/network/networkrun.cpp
+++ b/noncore/settings/networksettings2/network/networkrun.cpp
@@ -9,58 +9,58 @@ void NetworkRun::detectState( NodeCollection * NC ) {
if( II ) {
// device has assigned interface
NC->setCurrentState( (( II->IsUp ) ? IsUp : Available) );
return;
}
// has no interface -> delegate
RI->detectState( NC );
}
bool NetworkRun::setState( NodeCollection * NC, Action_t A ) {
// we handle UP and DOWN
RuntimeInfo * RI = netNode()->nextNode()->runtime();
AsDevice * Next = RI->asDevice();
InterfaceInfo * II = Next->assignedInterface();
if( A == Up ) {
// we can bring UP if lower level is available
if( NC->currentState() == Available ) {
QString S;
S.sprintf( "ifup %s=%s-c%d-allowed",
II->Name.latin1(), II->Name.latin1(),
connection()->number() );
- NSResources->system().execute( S );
+ NSResources->system().runAsRoot( S );
}
return 1;
} else if( A == Down ) {
if( NC->currentState() == IsUp ) {
QString S;
S.sprintf( "ifdown %s=%s-c%d-allowed",
II->Name.latin1(), II->Name.latin1(),
connection()->number() );
- NSResources->system().execute( S );
+ NSResources->system().runAsRoot( S );
}
return 1;
}
// delegate
return RI->setState( NC, A );
}
bool NetworkRun::canSetState( State_t Curr, Action_t A ) {
// we handle UP and DOWN
RuntimeInfo * RI = netNode()->nextNode()->runtime();
if( A == Up ) {
return ( Curr == Available );
} else if( A == Down ) {
return ( Curr == IsUp );
}
// delegate
return RI->canSetState( Curr, A );
}
bool NetworkRun::handlesInterface( const QString & S ) {
// donno -> pass deeper
return netNode()->nextNode()->runtime()->handlesInterface(S);
}