What is the syntax of DISPLAY environment variable? - linux

I'm writing program in x86-64 assembly for linux that will create X11 window using only system calls invoked with syscall instruction. Based on the content of the DISPLAY environment variable I have to create either tcp or unix socket. In linux manual "man 7 X" it is written that :
The hostname part of the display name should be the empty string. For example: :0, :1, and :0.1. The most efficient local transport will be chosen.
However I compiled C code example from https://en.wikibooks.org/wiki/X_Window_Programming/XCB and ran compiled executable in GDB with changed DISPLAY environment variable. When I change DISPLAY environment variable from DISPLAY=:0 to DISPLAY=unix:0 or DISPLAY=unix/:0 or DISPLAY=unix/abc:0 window is still created. Is linux manual wrong and what is real syntax of DISPLAY environment variable?

Short Answer: X11 can run over multiple transport. The comment is related to 'local' connection.
Long Answer:
The quote that you include refers to 'local' connection. The X11 system can run over few tarnsport layers. On my system:
local
The hostname part of the display name should be the empty string. For example: :0, :1, and :0.1. The most effi‐
cient local transport will be chosen.
TCPIP
The hostname part of the display name should be the server machine's hostname or IP address. Full Internet names,
abbreviated names, IPv4 addresses, and IPv6 addresses are all allowed. For example: x.org:0, expo:0, [::1]:0,
198.112.45.11:0, bigmachine:1, and hydra:0.1.
Also, many systems support running over unix sockets, which had (at least in the past) more efficient that TCP connections.

Related

How do I change a variable value in Xilinx SDK debugger using Linux TCF Agent connected to our target?

I am connected to our target over ethernet using the Linux TCF agent to debug an application.
I've used a lot of debuggers over my 25 year career, but this is my first time using Eclipse/Linux/Xilinx environment. I can set break points. I can single step through the code. I can view variables. I can view memory. I can type a new value in the memory location, but the variable value doesn't change. I tried to click or double click the value in the Variables pane. I tried right clicking to see if it would give me an option to modify the value.
I'm not sure what good a debugging tool is if I can't change a variable value to alter the execution path of my software...
In addition to the hacky solution we came up in the comments, which is to get the address of a variable and then modify them through the mr command from the xsct console, the same console provide commands to properly get/set a local variable.
The syntax is the following:
locals [options] [variable-name [variable-value]]
And an example:
locals my_int_var 10
locals my_float_var 1.4

Inno Setup mac id verification for multiple network adapters & Single network adaptors

I am new to Inno setup ,
I have a Question here
when I execute "getmac" command from cmd line i got following output. I got multiple mac addresses ( I have installed VM Virtual player in my machine )
And by the time when i uninstall VM virtual player and up on execution of same command i got different output, following is the screen shot for that .
My issue here is,
1.Which mac address I need to consider among multiple mac address at the time of creating EXE file for MAC validation.
2.At the time of installation INNO Setup will fetch the MAC address from the local machine and it will compare the with the mac address what we have given at the time of creating the EXE file using mac address. In this case if the machine has multiple mac addresses, which mac address will Inno Setup will take to compare.
In my case I have created EXE file using Inno setup with my mac address, at the time of creating the exe file my machine has single mac address later I installed VM player then my machine has couple of mac addresses and I try to install after installing VM palyer Inno setup is considering newly created MAC ADDRESS, and saying MAC address not valid **
Does any have idea how to solve this.**
Thanks in Advance :-)
I do not think you have a technical problem; I think you need to understand ao Inno setup works. The person who does the installation needs to be aware that the MAC address chosen will be the one used to validate the product and that choosing the wrong MAC address will prevent the product from running if that MAC address is no longer in the system. For example, read poin 3 here https://support.minitab.com/en-us/installation/frequently-asked-questions/license-fulfillment/which-mac-address-to-fufill-license/
Now, keep in mind that MAC addresses can easily be spoofed. You can exert some control by not allowing certain MAC addresses, for example these https://macaddress.io/faq/how-to-recognise-a-vmwares-virtual-machine-by-its-mac-address and by taking into consideration what the IEEE Standards Association says in the Guidelines for Use of Extended Unique Identifier (EUI), Organizationally Unique Identifier (OUI), and Company ID (CID) available here: https://standards.ieee.org/content/dam/ieee-standards/standards/web/documents/tutorials/eui.pdf
This is about all you can do. If you don't exclude any MAC address than it would be very easy to run the installation on a different machine because one would be able to replicate the valid MAC address.
If you need to find only permanent MAC address, you should begin by filtering the NICs that are physical:
wmic nic where "PhysicalAdapter='True'"
Once you have that list, you'll find that some virtual interfaces still appear as physical.
A good way to filter them is to check their device path since only real network cards are connected to the PCI bus.
This also would apply to USB bus, but since those cards aren't permanently connected, you can safely ignore them.
A good way to retrieve the device path togheter with the MAC address would be
wmic nic where "PhysicalAdapter='True'" get MACAddress,PNPDeviceID
which would output something like:
MACAddress PNPDeviceID
E0:94:67:XX:XX:XX PCI\VEN_8086&DEV_3165&SUBSYS_40108086&REV_81\E094XXXXXXXXXXXXXX
D8:CB:8A:XX:XX:XX PCI\VEN_1969&DEV_E0A1&SUBSYS_115A1462&REV_10\FFEFXXXXXXXXXXXXXX
E0:94:67:XX:XX:XX BTH\MS_BTHPAN\6&5XXXXXXXXXX
In the above example you can see two "real" ethernet network interfaces (wifi and eth), and a bluetooth device.
Just filter by keyword PCI and you got yourself the list of non mutable mac addresses.
You can filter via inno setup turbo pascal functions, or via cmd.
The final result could look like:
wmic nic where "PhysicalAdapter='True'" get MACAddress,PNPDeviceID | findstr "PCI"
If you want to show only the MAC addresses, you can wrap the whole thing in a batch script (which IMO isn't the best idea since it's a messy script language):
for /f "delims=" %%i in ('wmic nic where "PhysicalAdapter='True'" get MacAddress^,PNPDeviceID ^| findstr PCI') do (set res=%%i && echo %res:~0,17%)
Note the ^ sign before the comma and the pipe, that acts like an escape character so cmd doesn't take them as litterls.
There's also the Inno Setup way of doing by using a Pascal script.
Here's one I've modified (original here) to only list the MAC addresses of physical permanent interfaces.
Results in variable List:
WbemLocator := CreateOleObject('WbemScripting.SWbemLocator');
WbemServices := WbemLocator.ConnectServer('localhost', 'root\cimv2');
WQLQuery := 'Select MACAddress,PNPDeviceID from Win32_NetworkAdapter where PhysicalAdapter=true';
WbemObjectSet := WbemServices.ExecQuery(WQLQuery);
if not VarIsNull(WbemObjectSet) and (WbemObjectSet.Count > 0) then
begin
Result := WbemObjectSet.Count;
SetArrayLength(List, WbemObjectSet.Count);
for I := 0 to WbemObjectSet.Count - 1 do
begin
WbemObject := WbemObjectSet.ItemIndex(I);
if not VarIsNull(WbemObject) then
begin
if pos('PNP', WbemObject.PNPDeviceID) = 1 then
begin
List[I].MacAddress := WbemObject.MACAddress;
end;
end;
end;
end;
Note that this pascal script only works with win7+.
Hope one of these solutions fits you.

How can one connect to an abstract namespace unix family address in nodejs?

Has anybody tried to connect to an abstract namespace path (which starts with a null character) on unix family addresses in nodejs?
The problem seems to be that node internally sets the encoding of the path to ascii and consequently converts '\0' to space character. I tried buffers but didn't change anything.
If you wanna know what "abstract namespace" in unix address family means see the paragraph titled "abstract:" in "Address format" section of this link: http://man7.org/linux/man-pages/man7/unix.7.html
It seems that special module should be used for:
https://www.npmjs.org/package/abstractsocket
Since 0.12 this is supported by the core net module.
For 0.10:
The the module proposed by socketpair uses child process api and an external utility socat (similar to netcat), and does not let you create servers, just client connections.
A better alternative is https://www.npmjs.com/package/abstract-socket - it is a binary module instead.

test if hostname exists from command line without ping

we have a script that needs to take action on a finite list of hosts. but every time we add or remove a host to the /etc/hosts file, we end up having to update this script.
basically, say my hosts file looks like:
192.168.100.1 hostip_1
192.168.100.2 hostip_2
192.168.100.10 hostip_3
192.168.100.20 hostip_5
and my script (bash) does something like:
callmyfunction hostip_1
callmyfunction hostip_2
callmyfunction hostip_3
callmyfunction hostip_5
if i want to add hostip_4 to the list of hosts, i now have to go in and edit my script and add it to the list. while it's a small edit, it is still a step that can be forgotten in the process (especially if someone new to the system comes in).
is there a way i can test to see if 'hostip_1' is a valid hostname within the system (without pinging the host or grepping the /etc/hosts file)? we may use multiple hosts files, and different configurations may have different filenames, so i can't rely on trying to grep a single file. i need the system to do that work for me.
any clues?
first, my statement about things not being in the hosts file is wrong. that is exactly where they are. dumb on my part.
but the answer is:
getent hosts
that will get it to print everything out, and i can do a lookup from there.
As you are populating the /etc/hosts file, I am assuming that you are not using DNS. So below solution wont fit your use case. But it will still get you some pointers.
In a working DNS environment, you can check the host name to its corresponding IP with below command
# host host_name
This is will give the IP address of the host. In case the host name does not exists, then it will give you corresponding host not found message.
You can parse the output of above command and can deduce whether a give host name exists.
might not be in your /etc/hosts file... better search for the name and see if an ip can be found:
(($(dig +noall +answer google.de |wc -c)>0)) && echo exists
this is bash, can be adaptet to pretty much everything.
dig +noall +answer google.de
returns the ips if found. If empty, that name cannot be used in the computer running this code.
If all the targets are on the same subnet (same network), use arping, it will check that hosts are available using ARP.

How do I make my default (or any static) route permanent on Linux (Fedora 9 specifically)? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 1 year ago.
Improve this question
I've just performed a new installation of the very latest (Fall, 2008) version of Fedora 9 Linux and am perplexed that it never set the default route properly and that even traveling the labyrinthine ways of this OS, there's no obvious way.
Of course, it's clear that one can do it on a one-off basis like this:
route add default gw gw1 metric 0 eth0
or like this:
ip route add to default via 192.168.2.1 protocol static
However, neither of these survives reboot. In reading through /etc/rc.d/init.d/network, it attempts to find data from a file in /etc/sysconfig/static-routes, but that file never existed. So, I tried to create it and populate it with data. The trouble with that is that the script places a dash (minus sign) in an odd spot that I'm not sure how to deal with.
Of course, one can just edit /etc/rc.d/init.d/network, but that would be non-standard. As it is, my only other recourse seems to be editing rc.local, but that doesn't come early enough in the boot sequence to be there for things like, for example, the network time daemon.
I've done my homework - I've read all the man pages, info entries, tried apropos, and I've even done a fair bit of web searching, all to no avail - my next step, sans answer here, will be to sign up to the Fedora mailing lists and ask there! Or, give up and edit the scripts.
So, how is one supposed to do this?
The gateway is normally set in /etc/sysconfig/network-scripts/ifcfg-eth0, not in /etc/sysconfig/network. For example, on my current machine:
/etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=flyboys
NISDOMAIN=ekcineon
/etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
ONBOOT=yes
HWADDR=00:1d:09:31:3a:cc
NETMASK=255.255.255.0
IPADDR=150.102.65.30
GATEWAY=150.102.65.252
TYPE=Ethernet
Note that I set HWADDR because I have two ethernet cards and I want to make sure the right one is assigned to eth0. The configuration for the second card is in /etc/sysconfig/network-scripts/ifcfg-eth1
just edit the /etc/sysconfig/network-scripts/route-ethXX
and write inside: default via ip_address dev device , replace ip_address with your gateway ip and device with the name of the right eth device. but for the Device option its ... optional, set it in the case of multiple eth devices.
Works even in case of network restart, the route directive in rc.local works at boot only.
I have not used recent versions of Fedora, but it was often set as a GATEWAY variable in /etc/sysconfig/network.
Of course, if you just wanted it to work, you could just put the commands in /etc/rc.local to be executed when the boot sequence completes.
You can use nmcli if available, e.i.
# nmcli con show
NAME UUID TYPE DEVICE
System eth0 xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx ethernet eth0
ens33 xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx ethernet --
# nmcli con edit "System eth0"
nmcli> goto ipv4
You may edit the following properties: method, dns, dns-search, dns-options, dns-priority, addresses, gateway, routes, route-metric, route-table, routing-rules, ignore-auto-routes, ignore-auto-dns, dhcp-client-id, dhcp-timeout, dhcp-send-hostname, dhcp-hostname, dhcp-fqdn, never-default, may-fail, dad-timeout
nmcli ipv4>
nmcli ipv4> print
['ipv4' setting values]
ipv4.method: manual
ipv4.dns: --
ipv4.dns-search: --
ipv4.dns-options: --
ipv4.dns-priority: 0
ipv4.addresses: 10.10.10.1/26
ipv4.gateway: 10.10.10.129
ipv4.routes: --
ipv4.route-metric: -1
ipv4.route-table: 0 (unspec)
ipv4.routing-rules: --
ipv4.ignore-auto-routes: no
ipv4.ignore-auto-dns: no
ipv4.dhcp-client-id: --
ipv4.dhcp-timeout: 0 (default)
ipv4.dhcp-send-hostname: yes
ipv4.dhcp-hostname: --
ipv4.dhcp-fqdn: --
ipv4.never-default: no
ipv4.may-fail: yes
ipv4.dad-timeout: -1 (default)
nmcli ipv4>
nmcli ipv4> set routes 192.168.122.0/24 10.10.10.1
nmcli ipv4> verify
Verify setting 'ipv4': OK
nmcli ipv4> save
nmcli ipv4> quit
#nmcli con up "System eth0"
And it should create file /etc/sysconfig/network-scripts/routes- with proper parameters, e.g.
ADDRESS0=192.0.2.0
NETMASK0=255.255.255.0
GATEWAY0=198.51.100.1
Haven't seen Fedora. But shouldn't there be some GUI for this kind of thing? If you have Gnome try running gnome-network-preferences
Here it is for RHEL, as it is slightly different:
Identify the interface by using ifconfig
sudo vi /etc/sysconfig/network-scripts/route-ethXX
add the routes as per syntax below, where /xx represents subnet mask
host: 172.30.xxx.xxx via 172.30.xxx.xxx
network: 172.30.xxx.xxx/xx via 172.30.xxx.xxx
Default gateway: 0.0.0.0 via xxx.xxx.xxx.xxx</li>
Save the file.
sudo /etc/init.d/network restart (Warning: if you forget to set
correct routes for the management interface (if applicable) you may lose
connectivity to the server)

Resources