@@ -219,18 +219,10 @@ vipwedit (const char *file, int (*file_lock) (void), int (*file_unlock) (bool))
219219 if (shadowtcb_drop_priv () == SHADOWTCB_FAILURE ) {
220220 vipwexit (_ ("failed to drop privileges" ), errno , 1 );
221221 }
222- stprintf_a (fileedit ,
223- TCB_DIR "/" SHADOWTCB_SCRATCHDIR "/.%s.shadow.%s.XXXXXX" ,
224- Prog , user );
225- } else {
226- #endif /* WITH_TCB */
227- stprintf_a (fileedit , "/etc/.%s.XXXXXX" , Prog );
228- #ifdef WITH_TCB
229222 }
230- #endif /* WITH_TCB */
223+ #endif
231224 unlock = file_unlock ;
232225 filename = file ;
233- fileeditname = fileedit ;
234226
235227 if (access (file , F_OK ) != 0 ) {
236228 vipwexit (file , 1 , 1 );
@@ -274,6 +266,16 @@ vipwedit (const char *file, int (*file_lock) (void), int (*file_unlock) (bool))
274266 if (NULL == f ) {
275267 vipwexit (file , 1 , 1 );
276268 }
269+ #ifdef WITH_TCB
270+ if (tcb_mode ) {
271+ stprintf_a (fileedit ,
272+ TCB_DIR "/" SHADOWTCB_SCRATCHDIR "/.%s.shadow.%s.XXXXXX" ,
273+ Prog , user );
274+ } else
275+ #endif
276+ {
277+ stprintf_a (fileedit , "/etc/.%s.XXXXXX" , Prog );
278+ }
277279#ifdef WITH_TCB
278280 if (tcb_mode && (shadowtcb_gain_priv () == SHADOWTCB_FAILURE ))
279281 vipwexit (_ ("failed to gain privileges" ), errno , 1 );
@@ -282,6 +284,7 @@ vipwedit (const char *file, int (*file_lock) (void), int (*file_unlock) (bool))
282284 vipwexit (_ ("Couldn't make backup" ), errno , 1 );
283285 }
284286 (void ) fclose (f );
287+ fileeditname = fileedit ;
285288 createedit = true;
286289
287290 editor = getenv ("VISUAL" );
0 commit comments