Cannot use dollar in a NAGIOS custom object variable value - nagios

With nagios, I declare a host like this :
define host{
use aix-server
host_name test_passwd
alias test_passwd
address 10.4.15.75
hostgroups aix-servers
parents theparent
_LOGIN "testlog"
_PASSWD "1$dollar"
}
Look at the custom variable _PASSWD : NAGIOS 3.0.6 does not set correctly the corresponding environment variable passed to the check script:
NAGIOS__HOSTPASSWD=1dollar
The dollar character has disappeared !
I tried many escape possibilities seen on google but it does not seems to work for the custom objects variables values :
If I tried this
_PASSWD "1\\$$ \$\$ \\$\\$ \\$$ \$$ dollar"
The NAGIOS env var is then :
NAGIOS__HOSTPASSWD=1\\ \\ \\\\ \\ \ dollar
No dollar at all again.
So how can I put a dollar character into a value for a custom object variable ?

Check your nagios.cfg file for the following lines:
illegal_object_name_chars=`~!$%^&*"|'<>?,()=
illegal_macro_output_chars=`~$^&"|'<>
The second line is likely your target. Before changing either of those lines, read the docs as to why they exist and why they are set to those characters.

Enter it as a double dollar sign:
_PASSWD "1$$dollar"

Related

unicodePwd Attribute in AD

Can someone explain how the unicodePwd attribute works in AD.
Specifically, when I open the "ADSI Editor", then open a users properties and look at the attributes, the "unicodePwd" attribute shows as "not set". When in fact the user does have a password. Is this where password gets stored?
Also, I can reset a users password by right-clicking on the user and choosing Reset Password...but if I try to set by updating the unicodePwd, using proper Hex and I'm pretty sure using the right complexity, I get:
Operation Failed. Error code: 0x1f
SvcErr: DSID-031A1236, problem 5003 (WILL_NOT_PERFORM), data 0
I have been working on this for a while, and you cannot change the user password from the gui like that. There are two ways you can do this as far as I have found which is:
Use the powershell module found documented here: https://learn.microsoft.com/en-us/powershell/module/activedirectory/set-adaccountpassword?view=windowsserver2022-ps
Do it with the help of LDAP / OPENLDAP, like so:
a. add quotes (") to the beginning and end of the password
b. convert each character to unicode
c. convert the bytestring you now have using base 64 encoding.
The code I used to do the encoding is shown here:
import base64
import sys
def encode_pwd(pw):
new_pw = b""
pw = "\"" + pw + "\""
for char in pw:
new_pw += char.encode("utf-16le")
return base64.standard_b64encode(new_pw)
pw = sys.argv[1]
result = encode_pwd(pw)
stripped_result=str(result).strip("b'")
print(stripped_result)
This will return the encoded unicodePwd.
Finally modify the entry with ldapmodify:
ldapmodify -v -H 'ldaps://host' -U "user" -w "password" -Y DIGEST-MD5 \
<<EOF
dn: "DN=contoso,DN=com"
replace: unicodePwd
unicodePwd::$b64pwd
EOF
I hope this answers your question. :)
Active Directory stores the password on a user object or inetOrgPerson object in the unicodePwd attribute.
UnicodePwd doesn’t store the user password it is not set by default itself. It is use for encoding the password in a attribute.
This attribute can be written under restricted conditions, but it cannot be read. The attribute can only be modified; it cannot be added on object creation or queried by a search.
In order to modify this attribute, the client must have a 128-bit Transport Layer Security (TLS)/Secure Socket Layer (SSL) connection to the server. An encrypted session using SSP-created session keys using NTLM or Kerberos are also acceptable as long as the minimum key length is met.
Reference: https://learn.microsoft.com/en-us/troubleshoot/windows/win32/change-windows-active-directory-user-password
Note: The syntax of the unicodePwd attribute is Object(Replica-Link). However, the DC requires that the password value be specified in a UTF-16 encoded Unicode string containing the password surrounded by quotation marks, which has been BER-encoded as an octet string per the Object(Replica-Link) syntax.

How to set a context variable with dot in name?

I am trying to add a context data variable (CDV), which has a dot in its name. According to Adobe site this is correct:
s.contextData['myco.rsid'] = 'value'
Unfortunately, after calling s.t() the variable is split into two or more:
Context Variables
myco.:
rsid: value
.myco:
How can I set the variable and prevent splitting it into pieces?
You are setting it properly already. If you are referring to what you see in the request URL, that's how the Adobe library sends it. In your example, "myco" is a namespace, and "rsid" is a variable in that namespace. And you can have other variables in that namespace. For example if you have
s.contextData['myco.rsid1'] = 'value';
s.contextData['myco.rsid2'] = 'value';
You would see in the AA request URL (just showing the relevant part):
c.&myco.&rsid1=value&rsid2=value&.myco&.c
I assume you are asking because you want to more easily parse/qa AA collection request URLs from the browser network tab, extension, or some unit tester? There is no way to force AA to not behave like this when using dot syntax (namespaces) in your variables.
But, there isn't anything particularly special about using namespaces for your contextData variables; it's just there for your own organization if you choose. So if you want all variables to be "top level" and show full names in the request URL, then do not use dot syntax.
If you want to still have some measure of organization/hierarchy, I suggest you instead use an underscore _ :
s.contextData['myco_rsid1'] = 'value';
s.contextData['myco_rsid2'] = 'value';
Which will give you:
c.&myco_rsid1=value&myco_rsid2=value&.c
Side Note: You cannot do full object/dot notation syntax with s.contextData, e.g.
s.contextData = {
foo:'bar', // <--- this will properly parse
myco:{ // this will not properly parse
rsid:'value' //
} //
};
AA library does not parse this correctly; it just loops through top level properties of contextData when building the request URL. So if you do full object syntax like above, you will end up with:
c.&foo=bar&myco=%5Bobject%20Object%5D&&.c
foo would be okay, but you end up with just myco with "[object Object]" as the recorded value. Why Adobe didn't allow for full object syntax and just JSON.stringify(s.contextData) ? ¯\_(ツ)_/¯

omnet++ inet multi destination for udp packet (ini file)

my network is a mesh one. i want to send data from hostA* to hostB* .
a range is 3 (hostA0, hostA1, hostA2, hostA3), destination hosts are (hostB0, hostB1).
(hosts are in inet.node.inet.INetworkNode type).
how i set this property with wild card in scenario .ini file?
i try with
*.hostA*.udpApp[0].destAddresses = "hostB*"
*.hostA*.udpApp[0].destAddresses = "hostB0, hostB1"
*.hostA*.udpApp[0].destAddresses = "hostB0 hostB1"
*.hostA*.udpApp[0].destAddresses = "hostB${0,1}"
but they don't work. thanks.
You cannot use wildcard inside a string constant. Wildcards can be used only in the keys. The reason is that wildcards are not expanded like they are on a shell command line. Instead they work in a way that whenever you read in a parameter in omnet, it scans the INI file and returns the first matching parameter defined (taking into account the wildcard). So its rather matching the parameters instead of expanding them.
According the the docs of BasicUDPApp the space separated one (third one) should be used.

Import timeseries via loop (pot. generic)

Solved, now working example!
I have a set of time series that is populated in a folder structure as follows:
TimeSeriesData\Config_000000\seed_001\Aggregate_Quantity.txt
…
TimeSeriesData\Config_000058\seed_010\Aggregate_Quantity.txt
And in each file there is a first line containing a character, followed by lines containing the data. E.g.
share
-21.75
-20.75
…
Now, I would like to import all those files (at best, without specifying ex post the number of configs and seeds, at worst with supplying it) into single time series of the like: “AggQuant_config_seed” where config relates to the config ID and seed to the seed id.
I tried the following (using the non-preferred way), but “parsing” the “path” does not work / I do not know how to do it.
string base = "TimeSeriesData/Config_"
string middle = "/seed_"
string endd = "/Aggregate_Quantity.txt"
string path = ""
loop for (i=0;i<=58;i+=1)
loop for (j=1;j<=10;j+=1)
path = ""
sprintf path "%s%06d%s%03d%s",base,i,middle,j,endd
append #path #will be named share
rename share Agg_Q_$i_$j #rename
endloop
endloop
To sum up the problem, the following does not work:
string path="somwhere/a_file.txt" #string holding path
#wrong: append $path #use append on string
append #path #works!
And if possible, a way to search recursively through a set of folders, using the folder information together with file-information for the variable name, would be nice. Is that possible within gretl?
I realize that in many cases I would like to refer to a specific “help” section like those for functions and commands, but for operators instead (like “$”, which is obviously wrong here).

I want that the user can only type x.x.x.x in a Textbox

I want that the user can only type X.X.X.X in a Textbox (X is a number)
I tried a maskedTextbox and changed under properties the mask to:
//Mask: 9.9.9.9
//Previw: _,_,_,_
but when I got the value out of the maskedTextbox I get:
//Value: 1,1,1,1
is there a possibility that i can get:
//Value : 1.1.1.1
This is covered in the documentation for the Mask property:
.
Decimal placeholder. The actual display character used will be the decimal symbol appropriate to the format provider, as determined by the control's FormatProvider property.
...
\ Escape. Escapes a mask character, turning it into a literal. "\\" is the escape sequence for a backslash.
So you shouldn't be using . if you always want a period regardless of regional settings: you should use \. in that case.
I guess your culture creating problem as de-At treats . as , so you need to convert it to "."
try below code :-
System.Globalization.CultureInfo customCulture = (System.Globalization.CultureInfo)System.Threading.Thread.CurrentThread.CurrentCulture.Clone();
customCulture.NumberFormat.NumberDecimalSeparator = ".";
System.Threading.Thread.CurrentThread.CurrentCulture = customCulture;

Resources