- $self->SUPER::insert(@_)
- || $self->process_m2m(
- 'link_table' => 'radius_usergroup',
- 'target_table' => 'radius_group',
- 'params' => $self->usergroup,
- );
+
+ local $SIG{HUP} = 'IGNORE';
+ local $SIG{INT} = 'IGNORE';
+ local $SIG{QUIT} = 'IGNORE';
+ local $SIG{TERM} = 'IGNORE';
+ local $SIG{TSTP} = 'IGNORE';
+ local $SIG{PIPE} = 'IGNORE';
+
+ my $oldAutoCommit = $FS::UID::AutoCommit;
+ local $FS::UID::AutoCommit = 0;
+ my $dbh = dbh;
+
+ my $error = $self->SUPER::insert(@_)
+ || $self->process_m2m(
+ 'link_table' => 'radius_usergroup',
+ 'target_table' => 'radius_group',
+ 'params' => $self->usergroup,
+ );
+
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return $error;
+ }
+
+ $dbh->commit or die $dbh->errstr if $oldAutoCommit;
+ '';