Kali Linux removes the annoying "Warning: You are using a super account, which may damage your system" prompt

write first

The Kali Linux version in this article is 2022.3.
 I believe that many people will encounter these situations in the process of using Kali Linux:

insert image description here
p

 Regarding the warning bar in the middle of the interface of Thunar and Mousepad, let me tell you the truth, after all, Kali Linux is used, and users still don’t know how to use root (

 So I switched back and forth between Google and Bing, and finally found a few discussions about this bar, but the few tutorials I found didn't actually propose any practical solutions, and my solution process There are also many pitfalls. To sum up, I wrote this blog.

 So anyway, let's start now.

Tutorial starts

 Put the modified software first:
mousepad_0.5.10-1_amd64.deb
thunar_4.16.10-1_amd64.deb

general idea.

 First of all, Kali Linux uses "Warning: you are using the root account", which is the "Warning: You are using the super account, which may damage your system." This prompt actually comes from two software .

 The red prompt comes from a not-so-famous Linux open source text editor: Mousepad— Github link .

 The orange-red warning comes from the Thunar- Github link .

window.cLooking at the Github source code warehouses of the two softwares, you can find the corresponding code parts in the  corresponding files.

 Then it is very simple to deal with this matter, we only need to recompile and install these two softwares again.

Download the source code of the two software

 First of all, we must pay attention to one place, these two softwares are running on Xfce, that is to say, they are closely related to the version of xfce. Therefore, we cannot compile and install the latest version directly.

 First check the versions of these two software in Terminal.

insert image description here

 Then find the source code of the corresponding version in the code repository and download it.

make changes

 There are very few places that need to be changed, and it can be very easy if you don't know C language.

 The first is Thunar, directly use the search box to search for the keyword root , and then about line 731, we can find the following code block:

insert image description here

thunar-window.c part:

/* check if we need to add the root warning */
  if (G_UNLIKELY (geteuid () == 0)){
    
          
  /* add the bar for the root warning */      
  infobar = gtk_info_bar_new ();
  gtk_info_bar_set_message_type (GTK_INFO_BAR (infobar), GTK_MESSAGE_WARNING);      
  gtk_widget_set_hexpand (infobar, TRUE);      
  gtk_grid_attach (GTK_GRID (window->grid), infobar, 0, 2, 1, 1);      
  gtk_widget_show (infobar);      
  /* add the label with the root warning */      
  label = gtk_label_new (_("Warning: you are using the root account. You may harm your system."));      
  gtk_container_add (GTK_CONTAINER (gtk_info_bar_get_content_area (GTK_INFO_BAR (infobar))), label);      
  gtk_widget_show (label);    
  }

 Probably on line 731. Then delete all the parts placed in the above code block. After deletion, it will look like this:

insert image description here

 In the same way we deal with the source code of mousepad.

 The source code looks like this:

insert image description here

mousepad-window.c section

static void
mousepad_window_create_root_warning (MousepadWindow *window){
    
      
/* check if we need to add the root warning */  
if (G_UNLIKELY (geteuid () == 0)){
    
          
GtkWidget       *ebox, *label, *separator;      
GtkCssProvider  *provider;      
GtkStyleContext *context;      
const gchar     *css_string;      
/* add the box for the root warning */      
ebox = gtk_event_box_new ();      
gtk_box_pack_start (GTK_BOX (window->box), ebox, FALSE, FALSE, 0);      
gtk_widget_show (ebox);      
/* add the label with the root warning */      
label = gtk_label_new (_("Warning: you are using the root account. You may harm your system."));      
gtk_widget_set_margin_start (label, 6);      
gtk_widget_set_margin_end (label, 6);      
gtk_widget_set_margin_top (label, 3);      
gtk_widget_set_margin_bottom (label, 3);      
gtk_container_add (GTK_CONTAINER (ebox), label);      
gtk_widget_show (label);      
separator = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);      
gtk_box_pack_start (GTK_BOX (window->box), separator, FALSE, FALSE, 0);      
gtk_widget_show (separator);      
/* apply a CSS style to capture the user's attention */      
provider = gtk_css_provider_new ();      
css_string = "label { background-color: #b4254b; color: #fefefe; }";      
context = gtk_widget_get_style_context (label);
gtk_css_provider_load_from_data (provider, css_string, -1, NULL);      
gtk_style_context_add_provider (context, GTK_STYLE_PROVIDER (provider),                                      
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);      
g_object_unref (provider);    
	}
}

 Probably on line 1059. This processing method is slightly different from the Thunar above. We delete the method part inside, and the deletion is as follows:
insert image description here

 This part of the work is done.

compile

 This part is a bit torturous. It is recommended to compile on a Debian-based machine (you can use the server if possible, and the installed runtime software package is too lazy to delete), otherwise there will be a large number of required runtime libraries that cannot be found.

 First, open Terminal in the source code folder of the two software, take compiling mousepad as an example, and use it directly ./autogen.sh.

 The final result must be a failure, the compiler will prompt you that a certain package is missing, and then we must install this package. This is actually very simple, because there are a lot of packages required, so I won't list them one by one.

 Here are some things to pay attention to: the missing package is not the name mentioned in the prompt, we generally need a -devpackage with a suffix, you can apt search 包名search first to find the package with dev after the name. As shown below:

insert image description here

 After the painful installation of the runtime library, ./autogen.shit is ok to run repeatedly and get the following prompts:

insert image description here

 Then use makeit to compile, after the compilation is successful, it looks like this:

insert image description here

package installation

 First use apt removeto uninstall both packages, and then restart.

 It's slightly different here, we don't use make installto install, but use checkinstall.

checkinstallThere are many advantages. After installation, it will add the package to the dpkg management directory by default, and it can dpkg -r ***be used to .

 first useapt install checkinstall

 After that, you must name the source code folder in the format of packname-version , for example, it should be in the format of mousepad-0.5.10 , otherwise it will be very inconvenient to manage with the dpkg command.

 Use it directly in Temrinal checkinstallfor installation, during which it will prompt whether you need to add a description and confirm the package information, etc. If you don’t understand it, just press Enter all the way. If an error occurs, you can follow the prompt information to do some simple operations, such as delete A folder or file or something.

 After success, it looks like this:

insert image description here

 At the same time, the corresponding .debpackage will be generated in the directory.
insert image description here

 After compiling one of them, restart it immediately and then compile the second one. It may not be installed during the second compilation, but the deb package will appear, you can use the installation, and add dpkg -iparameters --force-allto force the installation to be overwritten, and then restart again.
 Let's see the effect

insert image description hereinsert image description here

Guess you like

Origin blog.csdn.net/m0_74075298/article/details/128175444